write a program to print roots of quadratic equation

1
Q WRITE A PROGRAM TO PRINT ROOTS OF QUADRATIC EQUATION #include<stdio.h> #include<math.h> int main() { int a,b,c; float x1,x2,l; printf(“Enter the coefficient of x^2 and x and constant term:”); scanf(“%d%d%d”,&a,&b,&c); printf(“Quadratic equation is %d(x^2)+%dx+%d=0.\ n”,a,b,c); l=sqrt(b*b-4*a*c); x1=(-b+l)/(2*a); x2=(-b-l)/(2*a); if(a==0) printf(“It is not a quadratic equation.”); else printf(“Roots of quadratic equation are %g and %g.\n”,x1,x2); return 0; } OUTPUT

Upload: vaunagarwal

Post on 24-Sep-2015

213 views

Category:

Documents


1 download

DESCRIPTION

Write a Program to Print Roots of Quadratic Equation

TRANSCRIPT

Q WRITE A PROGRAM TO PRINT ROOTS OF QUADRATIC EQUATION #include#includeint main(){int a,b,c;float x1,x2,l;printf(Enter the coefficient of x^2 and x and constant term:);scanf(%d%d%d,&a,&b,&c);printf(Quadratic equation is %d(x^2)+%dx+%d=0.\n,a,b,c);l=sqrt(b*b-4*a*c);x1=(-b+l)/(2*a);x2=(-b-l)/(2*a);if(a==0)printf(It is not a quadratic equation.);elseprintf(Roots of quadratic equation are %g and %g.\n,x1,x2);return 0;}OUTPUT