Skip to main content

Posts

Showing posts from March 15, 2009

C Program to calculate roots of quadratic equations

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.Also, we will have to include the math.h header. #include #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 and root2=%f",root1,root2); }