-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoot.cpp
More file actions
35 lines (35 loc) · 917 Bytes
/
Root.cpp
File metadata and controls
35 lines (35 loc) · 917 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
#include<stdio.h>
#include<math.h>
#include<ctype.h>
int main(){
float a,b,c,decision,root,sol1,sol2;
printf("!!!!!!!This Is A Solution To The Quandratic Equations!!!!!!!!\n");
printf("Enter The Co-Efficient of X^2:");
scanf("%f",&a);
printf("\nEnter The Co-Efficient of X:");
scanf("%f",&b);
printf("\nEnter The Constant:");
scanf("%f",&c);
decision=b*b-4*a*c;
root=sqrt(decision);
if(decision>=0){
if(decision==0){
printf("The Equation Has Unique Solution:\n");
sol1=-b/(2*a);
printf("Solution:%.3f",sol1);
}
else{
printf("The Equation Has Two Solutions:\n");
sol1=(-b+root)/(2*a);
sol2=(-b-root)/(2*a);
printf("Solutions:%.3f and %.3f",sol1,sol2);
}
}
else{
printf("The Equation Has Two Complex Solutions:\n");
root=sqrt(fabs(decision));
sol1=(-b)/(2*a);
sol2=(-b)/(2*a);
printf("Solutions:%.3f+%.3fi and %.3f-%.3fi",sol1,root,sol2,root);
}
}