please help me to correct this program
i don't know why the answer in the final is incorrect!!!
Code:#include<stdio.h> #include<math.h> #include<conio.h> void input() { float a,b,c; printf("Coefficient of X^2 = "); scanf("%f",&a); printf("Coefficient of X = "); scanf("%f",&b); printf("Constant term = "); scanf("%f",&c); } void quadratic(float a, float b, float c, float *d, float *root1, float *root2) { *d=pow(b,2)-(4*a*c); if (d>=0) { *root1=(-b+(sqrt(pow(b,2)-(4*b*c)))/(2*a)); *root2=(-b-(sqrt(pow(b,2)-(4*b*c)))/(2*a)); } } void output() { float d,root1,root2; if (d<0) printf("\nThe root of X are imaginary."); else if (d==0) printf("\nThe root of X is %g.",root1); else if (d>0) printf("\nThe roots of X are %g and %g.\n",root1,root2); } void main() { float a,b,c,d,root1,root2; input(); quadratic(a,b,c,&d,&root1,&root2); output(); }
[code][/code]tagged by Salem



LinkBack URL
About LinkBacks


