SE Experiment no 9

 download now



Boundary value analysis

#include<stdio.h>
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main(){
int a,b,c,d;
clrscr();
cout<<"The Quadratic equation is of the type a(x^2)+bx+c=0"<<endl;
cout<<"Enter the value of a: "<<endl;
cin>>a;
cout<<"Enter the value of b: "<<endl;
cin>>b;
cout<<"Enter the value of c: "<<endl;
cin>>c;
d=(b*b)-4*a*c;if((a<0)||(b<0)||(c<0)||(a>100)||(b>100)||(c>100))
cout<<"Invalid input"<<endl;
else if(a==0)
cout<<"Not a quadratic equation"<<endl;
else if (d==0)
cout<<"Roots are equal"<<endl;
else if(d<0)
cout<<"Imaginary roots"<<endl;
else
cout<<"Real Roots"<<endl;
getch();
}
OUTPUT:
The Quadratic equation is of the type a(x^2)+bx+c=0
Enter the value of a:
50
Enter the value of b:
50
Enter the value of c:
0
Real Roots
The Quadratic equation is of the type a(x^2)+bx+c=0
Enter the value of a:
50
Enter the value of b:
50
Enter the value of c:
50
Imaginary roots
The Quadratic equation is of the type a(x^2)+bx+c=0
Enter the value of a:
50
Enter the value of b:
100
Enter the value of c:
50
Roots are equal
Invalid input
The Quadratic equation is of the type a(x^2)+bx+c=0
Enter the value of a:
0
Enter the value of b:
50
Enter the value of c:
50
Not a quadratic equation

Equivalence Class Testing.

include <iostream.h>
#include<conio.h>
#include<math.h>
void main(){
int side1,side2,side3,match=0;
cout<<"Enter length of side1"<<endl;
cin>>side1;
cout<<"Enter length of side2"<<endl;
cin>>side2;
cout<<"Enter length of side3"<<endl;
cin>>side3;
if(side1==side2)
match=match+1;
else
if(side1==side3)
match=match+2;
else
if(side2==side3)
match=match+3;
if(match==0){
if((side1+side2)<=side3)
cout<<"not a triangle";
else{
if((side1+side3)<=side2)
cout<<"not a triangle";
else
cout <<"triangle is scalene";
}}
else
if(match==2){
if((side1+side3)<=side2)
cout<<"not a triangle";
else
cout<<"triangle is isosceles";
}
else
if(match==3){
if((side2+side3)<=side1)
cout<<"not a triangle";
else
cout<<"triangle is isosceles";
}
else{
cout<<"triangle is equilateral";}
getch();
}

OUTPUT1:
Enter length of side1
50
Enter length of side2
50
Enter length of side3
50
triangle is equilateral
OUTPUT2:
Enter length of side1
10
Enter length of side2
50
Enter length of side3
50
triangle is isosceles
OUTPUT3:
Enter length of side1
10
Enter length of side2
20
Enter length of side3
50
triangle is scalene
OUTPUT4:
Enter length of side1
10
Enter length of side2
30
Enter length of side3
50
not a triangle


SE Experiment no 9 SE Experiment no 9 Reviewed by akshay salve on 2:42 PM Rating: 5

No comments:

Powered by Blogger.