### completely stuck on this array problem for c

closed account (oj87ko23)
Write a main program allows the user to enter three coefficients of a quadratic equation. The main program passes the coefficients to the function. Write the function that finds and prints roots of the quadratic equation.
Last edited on
What have you tried?
closed account (oj87ko23)
int count 1;
double a,b,c,disc,real,img,r1,r2;
while (count<=5)
printf("Enter three values:");
scanf("%lf %lf %lf", &a &b &c);
disc=b*b-4ac
if(disc>0){
r1=(-b+sqrt(disc))/(2*a);
r2=(-b-sqrt(disc))/(2*a);
printf("r1=%2f r2=%2f", r1,r2);
}
else if (disc==0){
r1=-b/(2*a);
printf("r1=r2= %.2f",r1);
}
else
{
disc=-disc;
real=-b/(2*a);
img=sqrt(disc)/(2*a);
printf("roots are %.2f + j%2f, %2f-j%2f");\
real, img, real, img);
}
count = count +1;
}
return 0;
}
closed account (oj87ko23)
I can't figure out what to put into the function to return to the main program.
You should repost that inside codetags.
Assignment doesn't say the function has to return anything to main.
It says the function should "find and print the roots".

PLEASE USE CODE TAGS (the <> formatting button) when posting code. It makes it easier to read your code and also makes it easier to respond to your post.

Also, please post complete functions. The code you posted is not compilable.
Last edited on
Topic archived. No new replies allowed.