SlideShare a Scribd company logo
Name : Ejaz khan 
Roll no: 1120725 
Section CO-5 
Doc file is in office 365 it may behave 
differently in older versions of ms office 
SOFTWARE TESTING LAB 
Program 1. 
1. cyclometric complexity of a program(graph). 
//cyclomatic complexity 
#include<iostream> 
using namespace std; 
int main() 
{ 
int i,j,v,val,edg, arr[50][50];; 
cout<<" number of vertices"; 
cin>>v;
for(i=0;i<v;i++) 
{ 
for(j=0;j<v;j++) 
{ 
cin>>arr[i][j]; 
} 
} 
for(i=0;i<v;i++) 
{ 
for(j=0;j<v;j++) 
{ 
if(arr[i][j]==1) 
{ 
edg++; 
} 
} 
} 
cout<<"Complexity is:"<<edg-v+2;}
program 2. 
2. type of triangle given sides of triangle then perform 
boundary case analysis : 
//type of triangles and boundary value analysis 
#include<iostream> 
#include<conio.h> 
using namespace std; 
void triangle (int a,int b,int c) 
{ 
if((a<(b+c))&&(b<(a+c))&&(c<(a+b))) 
{ 
if(a==b&&b==c) 
{ 
cout<<"Equilateral Trianglen"; 
} 
else if ((a==b)||(a==c)||(b==c)) 
{ 
cout<<"Isosceles Trianglen"; 
} 
else 
{ 
cout<<"Scalene Trianglen";
} 
} 
else 
{ 
cout<<"Not a Trianglen"; 
} 
} 
int main() 
{ 
int x,y,z, no_of_test=0,i,j; 
cout<<"Enter the value of sides of triangle in the 
range 1-100n"; 
cin>>x>>y>>z; 
triangle (x,y,z); 
no_of_test =4*3+1; 
int min_range=1,max_range=100; 
int arr[4]={min_range,min_range+1,max_range- 
1,max_range}; 
int mid=(max_range-min_range)/2; 
cout<<"No. of boundary cases = "<< no_of_test 
<<endl; 
for(i=0;i<3;i++) 
{ 
for(j=0;j<4;j++) 
{ 
if(i==0) 
{
cout<<arr[j] <<" "<<(max_range-min_range)/2<<" 
"<<(max_range-min_range)/2<<endl; 
triangle (arr[j],mid,mid);} 
else if(i==1) 
{ 
cout<<(max_range-min_range)/2<<" "<<arr[j] <<" 
"<<(max_range-min_range)/2<<endl; 
triangle (mid,arr[j],mid);} 
else 
{ 
cout<<(max_range-min_range)/2<<" "<< 
(max_range-min_range)/2<<" "<<arr[j]<<endl; 
triangle (mid,mid,arr[j]);} 
} 
} 
cout<<(max_range-min_range)/2<<" "<<(max_range-min_ 
range)/2<<" "<<(max_range-min_range)/2<<endl; 
triangle (mid,mid,mid); 
getch(); 
}
Program 3. 
3. type of triangle given sides of triangle and operate 
robustness testing : 
//type of triangle using robustness testing analysis 
#include<iostream> 
#include<conio.h>
using namespace std; 
void triangle (int a,int b,int c) 
{ 
if((a<(b+c))&&(b<(a+c))&&(c<(a+b))) 
{ 
if(a==b&&b==c) 
{ 
cout<<"Equilateral Trianglen"; 
} 
else if ((a==b)||(a==c)||(b==c)) 
{ 
cout<<"Isosceles Trianglen"; 
} 
else 
{ 
cout<<"Scalene Trianglen"; 
} 
} 
else 
{ 
cout<<"Not a Trianglen"; 
} 
} 
int main() 
{ 
int x,y,z, no_of_test =0,i,j;
cout<<"Enter the value of sides of triangle in the 
range 1-100n"; 
cin>>x>>y>>z; 
triangle (x,y,z); 
no_of_test =6*3+1; 
int min_range=1,max_range=100; 
int arr[4]={min_range,min_range+1,max_range- 
1,max_range}; 
int mid=(max_range-min_range)/2; 
cout<<"No. of boundary cases = "<< no_of_test 
<<endl; 
for(i=0;i<3;i++) 
{ 
for(j=0;j<6;j++) 
{ 
if(i==0) {cout<<arr[j] <<" "<<(max_range-min_ 
range)/2<<" "<<(max_range-min_range)/2<<endl; 
triangle (arr[j],mid,mid);} 
else if(i==1) {cout<<(max_range-min_range)/2<<" 
"<<arr[j] <<" "<<(max_range-min_range)/2<<endl; 
triangle (mid,arr[j],mid);} 
else { cout<<(max_range-min_range)/2<<" 
"<< (max_range-min_range)/2<<" "<<arr[j]<<endl; 
triangle (mid,mid,arr[j]);}
} 
} 
cout<<(max_range-min_range)/2<<" "<<(max_range-min_ 
range)/2<<" "<<(max_range-min_range)/2<<endl; 
triangle (mid,mid,mid); 
getch(); 
}
Program 4 
4. find type of triangle and worst case testing : 
//type of triangle and Worst case analysis 
#include<iostream> 
#include<conio.h> 
#include<math.h> 
using namespace std; 
void triangle(int a,int b,int c) 
{ 
if((a<(b+c))&&(b<(a+c))&&(c<(a+b))) 
{ 
if(a==b&&b==c) 
{ 
cout<<"Equilateral Trianglen"; 
} 
else if ((a==b)||(a==c)||(b==c)) 
{ 
cout<<"Isosceles Trianglen"; 
} 
else 
{ 
cout<<"Scalene Trianglen"; 
} 
} 
else 
{ 
cout<<"Not a Trianglen";
} 
} 
int main() 
{ 
int x,y,z, no_of_test =0,i,j,k; 
cout<<"Enter the value of sides of triangle in the 
range 1-100n"; 
cin>>x>>y>>z; 
triangle (x,y,z); 
no_of_test =pow(5,3); 
int min_range=1,max_range=100; 
int arr[4]={min_range,min_range+1,max_range- 
1,max_range}; 
int mid=(max_range-min_range)/2; 
cout<<"No. of boundary cases = "<< no_of_test endl; 
for(i=0;i<5;i++) 
{ 
for(j=0;j<5;j++) 
{ 
for(k=0;k<5;k++) 
{ 
cout<<arr[i]<<” “<<arr[j]<<” 
“<<arr[k]<<endl; 
triangle (arr[i],arr[j],arr[k]); 
}}} 
5. find next date and perform boundary case analysis :
#include<iostream> 
#include<conio.h> 
using namespace std; 
int leap_year_year(int y) 
{ 
if(y%400==0||(y%4==0 && y%100!=0)) 
return 1; 
else 
return 0; 
} 
void next_date(int d,int m,int y) 
{ 
int 
mon1[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 
int 
mon2[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 
if(leap_year_year) 
{if(d==31&&m==12) 
{ 
cout<<"1-01-"<<y+1<<endl; 
return; 
} 
else if(d==mon2[m-1]) 
{cout<<1<<"-"<<m+1<<"-"<<y<<endl;
return; 
} 
else 
cout<<d+1<<"-"<<m<<"-"<<y<<endl; 
return; 
} 
else 
{ 
if(d==31&&m==12) 
{ 
cout<<"1-01-"<<y+1<<endl; 
return; 
} 
else if(d==mon1[m-1]) 
{cout<<1<<"-"<<m+1<<"-"<<y<<endl; 
return; 
} 
else 
cout<<d+1<<"-"<<m<<"-"<<y<<endl; 
return; 
}
} 
void next(int d,int m,int y) 
{ 
if(d<1) 
{cout<<"enter a valid daten"; 
return; 
} 
else if((d==29&&m==2)&& (!leap_year_year (y))) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else if(d>=29&&m==2) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else 
if((d==31&&m==4)||(d==31&&m==6)||(d==31&&m==9 
)||(d==31&&m==11)) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else if(d>31) 
{ cout<<"enter a valid daten"; 
return;
} 
else if(m<1||m>12) 
{ cout<<"enter a valid daten"; 
return; 
} 
next_date(d,m,y); 
} 
int main() 
{ 
int d,m,y,dd,mm,yy,i,j,k; 
int d1[4]={1,2,30,31}; 
int mid1=15,mid2=6,mid3=2500; 
int m1[4]={1,2,11,12}; 
int y1[4]={1,2,4999,5000}; 
cout<<"enter a date:"; 
cin>>d>>m>>y; 
next(d,m,y); 
int total_cases=4*3+1; 
cout<<"No. of boundary cases = "<<total_cases<<endl; 
for(i=0;i<3;i++)
{ 
for(j=0;j<4;j++) 
{ 
if(i==0) {cout<<d1[j] <<" "<<mid2<<" 
"<<mid3<<" "; 
next(d1[j],mid2,mid3);} 
else if(i==1) {cout<<mid1<<" "<<m1[j]<<" 
"<<mid3<<" "; 
next(mid1,m1[j],mid3);} 
else { cout<<mid1<<" "<< mid2<<" 
"<<y1[j]<<" "; 
next(mid1,mid2,y1[j]);} 
} 
} 
cout<<mid1<<" "<<mid2<<" "<<mid3<<" "; 
next(mid1,mid2,mid3); 
getch(); 
}
6. WAP to find next date and perform robustness 
testing : 
#include<iostream> 
#include<conio.h> 
using namespace std; 
int leap_year_year (int y) 
{ 
if(y%400==0||(y%4==0 && y%100!=0)) 
return 1;
else 
return 0; 
} 
void next_date(int d,int m,int y) 
{ 
int mon1[12]={31,28,31,30,31,30,31,31,30,31,30,3 
1}; 
int 
mon2[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 
if(leap_year_year (y)) 
{if(d==31&&m==12) 
{ 
cout<<"1-01-"<<y+1<<endl; 
return; 
} 
else if(d==mon2[m-1]) 
{cout<<1<<"-"<<m+1<<"-"<<y<<endl; 
return; 
} 
else 
cout<<d+1<<"-"<<m<<"-"<<y<<endl; 
return; 
}
else 
{ 
if(d==31&&m==12) 
{ 
cout<<"1-01-"<<y+1<<endl; 
return; 
} 
else if(d==mon1[m-1]) 
{cout<<1<<"-"<<m+1<<"-"<<y<<endl; 
return; 
} 
else 
cout<<d+1<<"-"<<m<<"-"<<y<<endl; 
return; 
} 
} 
void next(int d,int m,int y) 
{ 
if(y<0||y>5000) 
{ 
cout<<"enter a valid daten"; 
}
if(d<1) 
{cout<<"enter a valid daten"; 
return; 
} 
else if((d==29&&m==2)&& (!leap_year_year (y))) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else if(d>=29&&m==2) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else 
if((d==31&&m==4)||(d==31&&m==6)||(d==31&&m==9 
)||(d==31&&m==11)) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else if(d>31) 
{ cout<<"enter a valid daten"; 
return; 
} 
else if(m<1||m>12) 
{ cout<<"enter a valid daten";
return; 
} 
next_date(d,m,y); 
} 
int main() 
{ 
int d,m,y,dd,mm,yy,i,j,k; 
int d1[6]={0,1,2,30,31,32}; 
int mid1=15,mid2=6,mid3=2500; 
int m1[6]={0,1,2,11,12,13}; 
int y1[6]={0,1,2,4999,5000,5001}; 
cout<<"enter a date:"; 
cin>>d>>m>>y; 
next(d,m,y); 
int total_cases=6*3+1; 
cout<<"No. of boundary cases = "<<total_cases<<endl; 
for(i=0;i<3;i++) 
{ 
for(j=0;j<6;j++) 
{
if(i==0) {cout<<d1[j] <<" "<<mid2<<" 
"<<mid3<<" "; 
next(d1[j],mid2,mid3);} 
else if(i==1) {cout<<mid1<<" "<<m1[j]<<" 
"<<mid3<<" "; 
next(mid1,m1[j],mid3);} 
else { cout<<mid1<<" "<< mid2<<" 
"<<y1[j]<<" "; 
next(mid1,mid2,y1[j]);} 
} 
} 
cout<<mid1<<" "<<mid2<<" "<<mid3<<" "; 
next(mid1,mid2,mid3); 
}
7. WAP to find next date and perform worst case 
analysis : 
#include<iostream> 
#include<conio.h> 
using namespace std; 
int leap_year(int y) 
{ 
if(y%400==0||(y%4==0 && y%100!=0)) 
return 1; 
else 
return 0; 
} 
void find_next(int d,int m,int y) 
{ 
int mon1[12]={31,28,31,30,31,30,31,31,30,31,30,3 
1}; 
int 
mon2[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if(leap_year(y)) 
{if(d==31&&m==12) 
{ 
cout<<"1-01-"<<y+1<<endl; 
return; 
} 
else if(d==mon2[m-1]) 
{cout<<1<<"-"<<m+1<<"-"<<y<<endl; 
return; 
} 
else 
cout<<d+1<<"-"<<m<<"-"<<y<<endl; 
return; 
} 
else 
{ 
if(d==31&&m==12) 
{ 
cout<<"1-01-"<<y+1<<endl; 
return; 
} 
else if(d==mon1[m-1]) 
{cout<<1<<"-"<<m+1<<"-"<<y<<endl;
return; 
} 
else 
cout<<d+1<<"-"<<m<<"-"<<y<<endl; 
return; 
} 
} 
void next(int d,int m,int y) 
{ 
if(y<0&&y>5000) 
{ 
cout<<"enter a valid date"; 
return; 
} 
if(d<1) 
{cout<<"enter a valid daten"; 
return; 
} 
else if((d==29&&m==2)&& (!leap_year(y))) 
{ 
cout<<"enter a valid daten"; 
return; 
}
else if(d>=29&&m==2) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else 
if((d==31&&m==4)||(d==31&&m==6)||(d==31&&m==9 
)||(d==31&&m==11)) 
{ 
cout<<"enter a valid daten"; 
return; 
} 
else if(d>31) 
{ cout<<"enter a valid daten"; 
return; 
} 
else if(m<1||m>12) 
{ cout<<"enter a valid daten"; 
return; 
} 
find_next(d,m,y); 
}
int main() 
{ 
int d,m,y,dd,mm,yy,i,j,k; 
int d1[5]={1,2,15,30,31}; 
int mid1=15,mid2=6,mid3=2500; 
int m1[5]={1,2,6,11,12}; 
int y1[5]={1,2,2500,4999,5000}; 
//cout<<"enter a date:"; 
//cin>>d>>m>>y; 
//next(d,m,y); 
int total_cases=5*5*5; 
cout<<"No. of boundary cases = "<<total_cases<<endl; 
for(i=0;i<5;i++) 
{ 
for(j=0;j<5;j++) 
{ 
for(k=0;k<5;k++) 
{ 
cout<<d1[i]<<"-"<<"-"<<m1[j]<<"-"<<y1[k]<<" 
"; 
next(d1[i],m1[j],y1[k]); 
} 
}
}
8. Check whether the given equation is quadratic and 
also check the nature of its roots and preform worst 
case analysis: 
#include<iostream> 
#include<conio.h> 
using namespace std; 
void quad(int a, int b,int c) 
{ 
int d=b*b-4*a*c; 
if(a==0) 
{ 
cout<<"Given equation is not quadraticn"; 
} 
else 
{ 
if(d>=0) 
{ 
if(d==0) 
cout<<"Roots are real and equal "; 
else 
cout<<"Root are real and distinct "; 
float r1,r2; 
r1=(-b+sqrt(d))/(2*a); 
r2=(-b-sqrt(d))/(2*a);
cout<<r1<<" "<<r2<<endl; 
} 
else 
cout<<”roots are imaginaryn”; 
} 
} 
int main() 
{ 
int a,b,c,total_cases=0,i,j,k; 
int min_range=1,max_range=100; 
int mid=(max_range-min_range)/2; 
int arr[5]={min_range,min_range+1,mid,max_range- 
1,max_range}; 
cout<<"enter coefficeint a,b,c of the quadratic 
equation"<<endl; 
cin>>a>>b>>c; 
check(a,b,c); 
total_cases=5*5*5; 
cout<<"No. of boundary cases = "<<total_cases<<endl;
for(i=0;i<5;i++) 
{ 
for(j=0;j<5;j++) 
{ 
for(k=0;k<5;k++) 
{ 
cout<<arr[i]<<" "<<arr[j]<<" "<<arr[k]<<" "; 
check(arr[i],arr[j],arr[k]); 
} 
} 
} 
}

More Related Content

PDF
Asssignment2
PDF
Yoyak ScalaDays 2015
PDF
Geometric nonlinearity analysis of springs with rigid element displacement co...
PDF
Nonlinear analysis of braced frame with hinge by hinge method in c programming
DOC
Ds 2 cycle
DOC
Ocr code
DOCX
Java binary subtraction
PDF
Pemrograman visual
Asssignment2
Yoyak ScalaDays 2015
Geometric nonlinearity analysis of springs with rigid element displacement co...
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Ds 2 cycle
Ocr code
Java binary subtraction
Pemrograman visual

What's hot (20)

PDF
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
PPTX
Software engineering
PDF
The Ring programming language version 1.5.4 book - Part 59 of 185
PDF
Functional C++
PDF
Encoder + decoder
PDF
Standford 2015 week9
PPTX
A Test of Strength
PDF
Property-based testing
PDF
Gaurav Jatav , BCA Third Year
TXT
Los dskn
PPTX
Hypercritical C++ Code Review
DOCX
PDF
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
PDF
The Ring programming language version 1.3 book - Part 50 of 88
PPTX
Detection of errors and potential vulnerabilities in C and C++ code using the...
PPTX
Css grid-layout
PDF
662305 LAB13
PPTX
Secure and privacy-preserving data transmission and processing using homomorp...
PPTX
Mythbusting: Understanding How We Measure Performance at MongoDB
PDF
C++ L04-Array+String
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Software engineering
The Ring programming language version 1.5.4 book - Part 59 of 185
Functional C++
Encoder + decoder
Standford 2015 week9
A Test of Strength
Property-based testing
Gaurav Jatav , BCA Third Year
Los dskn
Hypercritical C++ Code Review
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
The Ring programming language version 1.3 book - Part 50 of 88
Detection of errors and potential vulnerabilities in C and C++ code using the...
Css grid-layout
662305 LAB13
Secure and privacy-preserving data transmission and processing using homomorp...
Mythbusting: Understanding How We Measure Performance at MongoDB
C++ L04-Array+String
Ad

Viewers also liked (20)

PDF
Specialty Vegetables
PDF
PDF
Chlorrid msds
PPT
делегация гимназии 67 на российском фестивале
PDF
Hog Production Alternatives
PDF
Energy-Efficient Lighting for the Farm
PDF
Sustainable Fire Ant Management
PDF
Organic Small Grain Production
PDF
Sustainable Cotton Production for the Humid South
PDF
Hooped Shelters for Hogs
PDF
Xeriscape Gardening Technology
PPTX
Vin open hernia debate asimanicon 2015
PDF
City Beekeeping ~ Honey for Health
DOCX
Resume
PDF
E&B Oil Company's Legal Letter To The City Og Hermosa Beach About The FEIR
PDF
Bamboo: A Multipurpose Agroforestry Crop
PDF
Plug and Transplant Production for Organic Systems
PPTX
Ransomware History and Monitoring Tips
PDF
Sustainable Corn and Soybean Production
PPTX
Facebook для бизнеса
Specialty Vegetables
Chlorrid msds
делегация гимназии 67 на российском фестивале
Hog Production Alternatives
Energy-Efficient Lighting for the Farm
Sustainable Fire Ant Management
Organic Small Grain Production
Sustainable Cotton Production for the Humid South
Hooped Shelters for Hogs
Xeriscape Gardening Technology
Vin open hernia debate asimanicon 2015
City Beekeeping ~ Honey for Health
Resume
E&B Oil Company's Legal Letter To The City Og Hermosa Beach About The FEIR
Bamboo: A Multipurpose Agroforestry Crop
Plug and Transplant Production for Organic Systems
Ransomware History and Monitoring Tips
Sustainable Corn and Soybean Production
Facebook для бизнеса
Ad

Similar to C programs (20)

PPT
Advanced Search Techniques
PDF
Problem DefinitionBuild a Date class and a main function to test i.pdf
PDF
Please follow the cod eand comments for description CODE #incl.pdf
DOCX
#include iostream#includectimeusing namespace std;void.docx
PDF
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
PDF
Binary search: illustrated step-by-step walk through
DOCX
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
PPT
Software Quality Testing
PDF
COA_remaining_lab_works_077BCT033.pdf
PDF
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
PPT
Chap08alg
PPT
Chap08alg
DOCX
Assignement of programming & problem solving
PPTX
Ranges calendar-novosibirsk-2015-08
DOC
oop Lecture 4
PPT
Computer Programming- Lecture 9
PPTX
Data Structures and algorithms using dynamicProgramming
DOCX
C++ file
DOCX
C++ file
PPTX
Dynamic programming - fundamentals review
Advanced Search Techniques
Problem DefinitionBuild a Date class and a main function to test i.pdf
Please follow the cod eand comments for description CODE #incl.pdf
#include iostream#includectimeusing namespace std;void.docx
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
Binary search: illustrated step-by-step walk through
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Software Quality Testing
COA_remaining_lab_works_077BCT033.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
Chap08alg
Chap08alg
Assignement of programming & problem solving
Ranges calendar-novosibirsk-2015-08
oop Lecture 4
Computer Programming- Lecture 9
Data Structures and algorithms using dynamicProgramming
C++ file
C++ file
Dynamic programming - fundamentals review

Recently uploaded (20)

PPTX
Biodiversity of nature in environmental studies.pptx
DOCX
Double Membrane Roofs for Biogas Tanks Securely store produced biogas.docx
PPTX
NSTP1 NSTP1NSTP1NSTP1NSTP1NSTP1NSTP1NSTP
PPTX
Importance of good air quality and different pollutants.
PPTX
Plant_Cell_Presentation.pptx.com learning purpose
PDF
1748933543SJA_41_2_826-834 SJA Ihsan ullha.pdf
PPTX
Microbial-Pathogens-and-Parasites-Their-Impact-on-Plant-Health.pptx
PPT
Environmental pollution for educational study
PDF
Tree Biomechanics, a concise presentation
PPTX
the solar system janDNsdnfanscssfsaaansf
DOCX
Double Membrane Roofs for Bio-gas Tanks Reliable containment for biofuel gas....
PPTX
Conformity-and-Deviance module 7 ucsp grade 12
PPTX
RadiationSafetyPt120252026nucchemis.pptx
DOCX
Double Membrane Roofs for Agricultural Waste Biogas Digesters Turns various f...
PDF
Global Natural Disasters in H1 2025 by Beinsure
PPTX
AUTO IRRIGATION USING GRID SYSTEM123.pptx
PPTX
Environmental pollutants for natural res
PDF
Cave Diggers Simplified cave survey methods and mapping
PPT
PPTPresentation3 jhsvdasvdjhavsdhsvjcksjbc.jasb..ppt
PDF
Effective factors on adoption of intercropping and it’s role on development o...
Biodiversity of nature in environmental studies.pptx
Double Membrane Roofs for Biogas Tanks Securely store produced biogas.docx
NSTP1 NSTP1NSTP1NSTP1NSTP1NSTP1NSTP1NSTP
Importance of good air quality and different pollutants.
Plant_Cell_Presentation.pptx.com learning purpose
1748933543SJA_41_2_826-834 SJA Ihsan ullha.pdf
Microbial-Pathogens-and-Parasites-Their-Impact-on-Plant-Health.pptx
Environmental pollution for educational study
Tree Biomechanics, a concise presentation
the solar system janDNsdnfanscssfsaaansf
Double Membrane Roofs for Bio-gas Tanks Reliable containment for biofuel gas....
Conformity-and-Deviance module 7 ucsp grade 12
RadiationSafetyPt120252026nucchemis.pptx
Double Membrane Roofs for Agricultural Waste Biogas Digesters Turns various f...
Global Natural Disasters in H1 2025 by Beinsure
AUTO IRRIGATION USING GRID SYSTEM123.pptx
Environmental pollutants for natural res
Cave Diggers Simplified cave survey methods and mapping
PPTPresentation3 jhsvdasvdjhavsdhsvjcksjbc.jasb..ppt
Effective factors on adoption of intercropping and it’s role on development o...

C programs

  • 1. Name : Ejaz khan Roll no: 1120725 Section CO-5 Doc file is in office 365 it may behave differently in older versions of ms office SOFTWARE TESTING LAB Program 1. 1. cyclometric complexity of a program(graph). //cyclomatic complexity #include<iostream> using namespace std; int main() { int i,j,v,val,edg, arr[50][50];; cout<<" number of vertices"; cin>>v;
  • 2. for(i=0;i<v;i++) { for(j=0;j<v;j++) { cin>>arr[i][j]; } } for(i=0;i<v;i++) { for(j=0;j<v;j++) { if(arr[i][j]==1) { edg++; } } } cout<<"Complexity is:"<<edg-v+2;}
  • 3. program 2. 2. type of triangle given sides of triangle then perform boundary case analysis : //type of triangles and boundary value analysis #include<iostream> #include<conio.h> using namespace std; void triangle (int a,int b,int c) { if((a<(b+c))&&(b<(a+c))&&(c<(a+b))) { if(a==b&&b==c) { cout<<"Equilateral Trianglen"; } else if ((a==b)||(a==c)||(b==c)) { cout<<"Isosceles Trianglen"; } else { cout<<"Scalene Trianglen";
  • 4. } } else { cout<<"Not a Trianglen"; } } int main() { int x,y,z, no_of_test=0,i,j; cout<<"Enter the value of sides of triangle in the range 1-100n"; cin>>x>>y>>z; triangle (x,y,z); no_of_test =4*3+1; int min_range=1,max_range=100; int arr[4]={min_range,min_range+1,max_range- 1,max_range}; int mid=(max_range-min_range)/2; cout<<"No. of boundary cases = "<< no_of_test <<endl; for(i=0;i<3;i++) { for(j=0;j<4;j++) { if(i==0) {
  • 5. cout<<arr[j] <<" "<<(max_range-min_range)/2<<" "<<(max_range-min_range)/2<<endl; triangle (arr[j],mid,mid);} else if(i==1) { cout<<(max_range-min_range)/2<<" "<<arr[j] <<" "<<(max_range-min_range)/2<<endl; triangle (mid,arr[j],mid);} else { cout<<(max_range-min_range)/2<<" "<< (max_range-min_range)/2<<" "<<arr[j]<<endl; triangle (mid,mid,arr[j]);} } } cout<<(max_range-min_range)/2<<" "<<(max_range-min_ range)/2<<" "<<(max_range-min_range)/2<<endl; triangle (mid,mid,mid); getch(); }
  • 6. Program 3. 3. type of triangle given sides of triangle and operate robustness testing : //type of triangle using robustness testing analysis #include<iostream> #include<conio.h>
  • 7. using namespace std; void triangle (int a,int b,int c) { if((a<(b+c))&&(b<(a+c))&&(c<(a+b))) { if(a==b&&b==c) { cout<<"Equilateral Trianglen"; } else if ((a==b)||(a==c)||(b==c)) { cout<<"Isosceles Trianglen"; } else { cout<<"Scalene Trianglen"; } } else { cout<<"Not a Trianglen"; } } int main() { int x,y,z, no_of_test =0,i,j;
  • 8. cout<<"Enter the value of sides of triangle in the range 1-100n"; cin>>x>>y>>z; triangle (x,y,z); no_of_test =6*3+1; int min_range=1,max_range=100; int arr[4]={min_range,min_range+1,max_range- 1,max_range}; int mid=(max_range-min_range)/2; cout<<"No. of boundary cases = "<< no_of_test <<endl; for(i=0;i<3;i++) { for(j=0;j<6;j++) { if(i==0) {cout<<arr[j] <<" "<<(max_range-min_ range)/2<<" "<<(max_range-min_range)/2<<endl; triangle (arr[j],mid,mid);} else if(i==1) {cout<<(max_range-min_range)/2<<" "<<arr[j] <<" "<<(max_range-min_range)/2<<endl; triangle (mid,arr[j],mid);} else { cout<<(max_range-min_range)/2<<" "<< (max_range-min_range)/2<<" "<<arr[j]<<endl; triangle (mid,mid,arr[j]);}
  • 9. } } cout<<(max_range-min_range)/2<<" "<<(max_range-min_ range)/2<<" "<<(max_range-min_range)/2<<endl; triangle (mid,mid,mid); getch(); }
  • 10. Program 4 4. find type of triangle and worst case testing : //type of triangle and Worst case analysis #include<iostream> #include<conio.h> #include<math.h> using namespace std; void triangle(int a,int b,int c) { if((a<(b+c))&&(b<(a+c))&&(c<(a+b))) { if(a==b&&b==c) { cout<<"Equilateral Trianglen"; } else if ((a==b)||(a==c)||(b==c)) { cout<<"Isosceles Trianglen"; } else { cout<<"Scalene Trianglen"; } } else { cout<<"Not a Trianglen";
  • 11. } } int main() { int x,y,z, no_of_test =0,i,j,k; cout<<"Enter the value of sides of triangle in the range 1-100n"; cin>>x>>y>>z; triangle (x,y,z); no_of_test =pow(5,3); int min_range=1,max_range=100; int arr[4]={min_range,min_range+1,max_range- 1,max_range}; int mid=(max_range-min_range)/2; cout<<"No. of boundary cases = "<< no_of_test endl; for(i=0;i<5;i++) { for(j=0;j<5;j++) { for(k=0;k<5;k++) { cout<<arr[i]<<” “<<arr[j]<<” “<<arr[k]<<endl; triangle (arr[i],arr[j],arr[k]); }}} 5. find next date and perform boundary case analysis :
  • 12. #include<iostream> #include<conio.h> using namespace std; int leap_year_year(int y) { if(y%400==0||(y%4==0 && y%100!=0)) return 1; else return 0; } void next_date(int d,int m,int y) { int mon1[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int mon2[12]={31,28,31,30,31,30,31,31,30,31,30,31}; if(leap_year_year) {if(d==31&&m==12) { cout<<"1-01-"<<y+1<<endl; return; } else if(d==mon2[m-1]) {cout<<1<<"-"<<m+1<<"-"<<y<<endl;
  • 13. return; } else cout<<d+1<<"-"<<m<<"-"<<y<<endl; return; } else { if(d==31&&m==12) { cout<<"1-01-"<<y+1<<endl; return; } else if(d==mon1[m-1]) {cout<<1<<"-"<<m+1<<"-"<<y<<endl; return; } else cout<<d+1<<"-"<<m<<"-"<<y<<endl; return; }
  • 14. } void next(int d,int m,int y) { if(d<1) {cout<<"enter a valid daten"; return; } else if((d==29&&m==2)&& (!leap_year_year (y))) { cout<<"enter a valid daten"; return; } else if(d>=29&&m==2) { cout<<"enter a valid daten"; return; } else if((d==31&&m==4)||(d==31&&m==6)||(d==31&&m==9 )||(d==31&&m==11)) { cout<<"enter a valid daten"; return; } else if(d>31) { cout<<"enter a valid daten"; return;
  • 15. } else if(m<1||m>12) { cout<<"enter a valid daten"; return; } next_date(d,m,y); } int main() { int d,m,y,dd,mm,yy,i,j,k; int d1[4]={1,2,30,31}; int mid1=15,mid2=6,mid3=2500; int m1[4]={1,2,11,12}; int y1[4]={1,2,4999,5000}; cout<<"enter a date:"; cin>>d>>m>>y; next(d,m,y); int total_cases=4*3+1; cout<<"No. of boundary cases = "<<total_cases<<endl; for(i=0;i<3;i++)
  • 16. { for(j=0;j<4;j++) { if(i==0) {cout<<d1[j] <<" "<<mid2<<" "<<mid3<<" "; next(d1[j],mid2,mid3);} else if(i==1) {cout<<mid1<<" "<<m1[j]<<" "<<mid3<<" "; next(mid1,m1[j],mid3);} else { cout<<mid1<<" "<< mid2<<" "<<y1[j]<<" "; next(mid1,mid2,y1[j]);} } } cout<<mid1<<" "<<mid2<<" "<<mid3<<" "; next(mid1,mid2,mid3); getch(); }
  • 17. 6. WAP to find next date and perform robustness testing : #include<iostream> #include<conio.h> using namespace std; int leap_year_year (int y) { if(y%400==0||(y%4==0 && y%100!=0)) return 1;
  • 18. else return 0; } void next_date(int d,int m,int y) { int mon1[12]={31,28,31,30,31,30,31,31,30,31,30,3 1}; int mon2[12]={31,28,31,30,31,30,31,31,30,31,30,31}; if(leap_year_year (y)) {if(d==31&&m==12) { cout<<"1-01-"<<y+1<<endl; return; } else if(d==mon2[m-1]) {cout<<1<<"-"<<m+1<<"-"<<y<<endl; return; } else cout<<d+1<<"-"<<m<<"-"<<y<<endl; return; }
  • 19. else { if(d==31&&m==12) { cout<<"1-01-"<<y+1<<endl; return; } else if(d==mon1[m-1]) {cout<<1<<"-"<<m+1<<"-"<<y<<endl; return; } else cout<<d+1<<"-"<<m<<"-"<<y<<endl; return; } } void next(int d,int m,int y) { if(y<0||y>5000) { cout<<"enter a valid daten"; }
  • 20. if(d<1) {cout<<"enter a valid daten"; return; } else if((d==29&&m==2)&& (!leap_year_year (y))) { cout<<"enter a valid daten"; return; } else if(d>=29&&m==2) { cout<<"enter a valid daten"; return; } else if((d==31&&m==4)||(d==31&&m==6)||(d==31&&m==9 )||(d==31&&m==11)) { cout<<"enter a valid daten"; return; } else if(d>31) { cout<<"enter a valid daten"; return; } else if(m<1||m>12) { cout<<"enter a valid daten";
  • 21. return; } next_date(d,m,y); } int main() { int d,m,y,dd,mm,yy,i,j,k; int d1[6]={0,1,2,30,31,32}; int mid1=15,mid2=6,mid3=2500; int m1[6]={0,1,2,11,12,13}; int y1[6]={0,1,2,4999,5000,5001}; cout<<"enter a date:"; cin>>d>>m>>y; next(d,m,y); int total_cases=6*3+1; cout<<"No. of boundary cases = "<<total_cases<<endl; for(i=0;i<3;i++) { for(j=0;j<6;j++) {
  • 22. if(i==0) {cout<<d1[j] <<" "<<mid2<<" "<<mid3<<" "; next(d1[j],mid2,mid3);} else if(i==1) {cout<<mid1<<" "<<m1[j]<<" "<<mid3<<" "; next(mid1,m1[j],mid3);} else { cout<<mid1<<" "<< mid2<<" "<<y1[j]<<" "; next(mid1,mid2,y1[j]);} } } cout<<mid1<<" "<<mid2<<" "<<mid3<<" "; next(mid1,mid2,mid3); }
  • 23. 7. WAP to find next date and perform worst case analysis : #include<iostream> #include<conio.h> using namespace std; int leap_year(int y) { if(y%400==0||(y%4==0 && y%100!=0)) return 1; else return 0; } void find_next(int d,int m,int y) { int mon1[12]={31,28,31,30,31,30,31,31,30,31,30,3 1}; int mon2[12]={31,28,31,30,31,30,31,31,30,31,30,31};
  • 24. if(leap_year(y)) {if(d==31&&m==12) { cout<<"1-01-"<<y+1<<endl; return; } else if(d==mon2[m-1]) {cout<<1<<"-"<<m+1<<"-"<<y<<endl; return; } else cout<<d+1<<"-"<<m<<"-"<<y<<endl; return; } else { if(d==31&&m==12) { cout<<"1-01-"<<y+1<<endl; return; } else if(d==mon1[m-1]) {cout<<1<<"-"<<m+1<<"-"<<y<<endl;
  • 25. return; } else cout<<d+1<<"-"<<m<<"-"<<y<<endl; return; } } void next(int d,int m,int y) { if(y<0&&y>5000) { cout<<"enter a valid date"; return; } if(d<1) {cout<<"enter a valid daten"; return; } else if((d==29&&m==2)&& (!leap_year(y))) { cout<<"enter a valid daten"; return; }
  • 26. else if(d>=29&&m==2) { cout<<"enter a valid daten"; return; } else if((d==31&&m==4)||(d==31&&m==6)||(d==31&&m==9 )||(d==31&&m==11)) { cout<<"enter a valid daten"; return; } else if(d>31) { cout<<"enter a valid daten"; return; } else if(m<1||m>12) { cout<<"enter a valid daten"; return; } find_next(d,m,y); }
  • 27. int main() { int d,m,y,dd,mm,yy,i,j,k; int d1[5]={1,2,15,30,31}; int mid1=15,mid2=6,mid3=2500; int m1[5]={1,2,6,11,12}; int y1[5]={1,2,2500,4999,5000}; //cout<<"enter a date:"; //cin>>d>>m>>y; //next(d,m,y); int total_cases=5*5*5; cout<<"No. of boundary cases = "<<total_cases<<endl; for(i=0;i<5;i++) { for(j=0;j<5;j++) { for(k=0;k<5;k++) { cout<<d1[i]<<"-"<<"-"<<m1[j]<<"-"<<y1[k]<<" "; next(d1[i],m1[j],y1[k]); } }
  • 28. }
  • 29. 8. Check whether the given equation is quadratic and also check the nature of its roots and preform worst case analysis: #include<iostream> #include<conio.h> using namespace std; void quad(int a, int b,int c) { int d=b*b-4*a*c; if(a==0) { cout<<"Given equation is not quadraticn"; } else { if(d>=0) { if(d==0) cout<<"Roots are real and equal "; else cout<<"Root are real and distinct "; float r1,r2; r1=(-b+sqrt(d))/(2*a); r2=(-b-sqrt(d))/(2*a);
  • 30. cout<<r1<<" "<<r2<<endl; } else cout<<”roots are imaginaryn”; } } int main() { int a,b,c,total_cases=0,i,j,k; int min_range=1,max_range=100; int mid=(max_range-min_range)/2; int arr[5]={min_range,min_range+1,mid,max_range- 1,max_range}; cout<<"enter coefficeint a,b,c of the quadratic equation"<<endl; cin>>a>>b>>c; check(a,b,c); total_cases=5*5*5; cout<<"No. of boundary cases = "<<total_cases<<endl;
  • 31. for(i=0;i<5;i++) { for(j=0;j<5;j++) { for(k=0;k<5;k++) { cout<<arr[i]<<" "<<arr[j]<<" "<<arr[k]<<" "; check(arr[i],arr[j],arr[k]); } } } }