-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboundery_value_analysis.cpp
41 lines (40 loc) · 1.14 KB
/
boundery_value_analysis.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
int a,b,c;
float x1,x2,d;
int status = 1;
printf("================Boundary Value Analysis===========\n");
while(status == 1)
{
printf("For Equation ax^2+bx+c = 0\n\n");
printf("\nEnter a:");scanf("%d",&a);
printf("\nEnter b:");scanf("%d",&b);
printf("\nEnter c:");scanf("%d",&c);
d = ((b*b)-(4*a*c));
x1 = ((-b)+pow(d,0.5))/(2*a);
x2 = ((-b)-pow(d,0.5))/(2*a);
if(a<1 || a>100 || b<0 || b>100 || c<0 || c>100)
{
printf("\nEntered values should be within 1 to 100\n");
}
else
{
cout<<"\nRoots are: "<<x1<<" and "<<x2<<"\n\n";
if(d > 0)
printf("Real and unequal roots\n");
if(d == 0)
printf("Real and same roots\n");
else
printf("imaginary roots\n");
}
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC;
printf("took %f seconds to execute \n", time_taken);
printf("\nDo you want to continue...?[1/0]\n");
scanf("%d",&status);
}
return 0;
}