forked from silent-killer-11/Hacktoberfest-2022
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtry.cpp
More file actions
36 lines (32 loc) · 806 Bytes
/
try.cpp
File metadata and controls
36 lines (32 loc) · 806 Bytes
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
/* C Program to find the roots of quadratic equation */
#include<stdio.h>
#include<math.h>
int main()
{
int A, B, C;
float disc, deno, x1, x2;
printf("ENTER THE VALUE OF A :: ");
scanf("%d", &A);
printf("\nENTER THE VALUE OF B :: ");
scanf("%d",&B);
printf("\nENTER THE VALUE OF C :: ");
scanf("%d",&C);
disc=(B*B)-(4*A*C);
deno = 2 * A;
if(disc > 0)
{
printf("\nTHE ROOTS ARE REAL ROOTS.");
x1 = (-B/deno)+(sqrt(disc)/deno);
x2 = (-B/deno)-(sqrt(disc)/deno);
printf("\n\nTHE ROOTS ARE :: %f and %f\n", x1, x2);
}
else if(disc == 0)
{
printf("\nTHE ROOTS ARE REPEATED ROOTS.");
x1 = -B/deno;
printf("\n\nTHE ROOT IS :: %f\n", x1);
}
else
printf("\nTHE ROOTS ARE IMAGINARY ROOTS.\n");
return 0;
}