Write a program in C/C++ to find the roots of a quadratic equation and perform the following on it: Boundary Value Analysis (BVA).
#include
#include
void main()
{
int a,b,c; int d=0; clrscr(); printf("The Quadratic Equation is of type ax2+bx+c=0"); printf("Enter value of a,b,c:"); scanf("%d \n %d \n %d",&a,&b,&c); d=((b*b)-(4*a*c)); if(a100)
{
printf("Invalid input");
}
if(d==0)
{
printf("Real and Equal Roots");
}
else if(d>0)
{
printf("Real roots");
}
else
{
printf("Not a quadratic equation");
}
getch();
}
Boundary Value Test Cases
In the above program, we consider the values as 0 (Minimum), 1 (Just above Minimum), 50
(Nominal), 99 (Just below Maximum) and 100 (Maximum)
Test
Case
ID
a
b
c
Expected Output
1
50
50
0
Real Roots
2
50
50
1
Real Roots
3
50
50
50
Imaginary Roots
4
50
50
99
Imaginary Roots
5
50
50
100
Imaginary Roots
6
50
0
50
Imaginary Roots
7
50
1
50
Imaginary Roots
8
50
99
50
Imaginary Roots
9
50
100
50
Equal Roots
10
0
50
50
Not a Quadratic
Equation
11
1
50
50
Real Roots
12
99
50
50
Imaginary Roots
13
100
50
50
Imaginary Roots
OUTPUT
PRACTICAL-2
Write a program in C/C++ to find the area of a circle, triangle, square and rectangle and perform the following: Equivalence Class testing.
#include
#include
void main()
{
int base=0,ht=0,a,rad,l,b; float cirar=0,triar=0; int rectar=0,sqar=0; int ch; clrscr(); do{ clrscr(); printf("\n 1. Area of triangle \n"); printf("2. Area of square \n"); printf("3. Area of circle\n"); printf("4. Area of rectangle \n"); printf("5. Exit\n"); printf("Enter choice:\n"); scanf("%d",&ch ); switch(ch) { case 1: clrscr(); printf("\n***Area of Triangle***"); a:printf("\nEnter base and height of triangle(1-200):"); scanf("%d \n