C Program to calculate roots of quadratic equations
This is a simple C program to calculate roots of quadratic equations.A function sqrt() is used in this program to find the square root.
This is a simple C program to calculate roots of quadratic equations.A function sqrt() is used in this program to find the square root.
#include
main()
{
int a,b,c,d;
float root1,root2;
printf("Enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=b*b-4*a*c;
root1=((-b)+sqrt(d))/(2*a);
root2=((-b)-sqrt(d))/(2*a);
printf("root1=%f & root2=%f",root1,root2);
}
main()
{
int a,b,c,d;
float root1,root2;
printf("Enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=b*b-4*a*c;
root1=((-b)+sqrt(d))/(2*a);
printf("root1=%f & root2=%f",root1,root2);
}



0 comments:
Post a Comment