[Solved] C program not printing out correct output


printf("%.3f+%.3fi", ((-b) / (2*a)), (sqrt(d) / (2 * a)));

You are using integer division in ((-b) / (2*a)) So you will get incorrect values for some numbers.

You can use.

printf("%.3f+%.3fi", ((-b) / (2.0*a)), (sqrt(d) / (2 * a)));

to force a conversion to a double before the division. You need to do this for all division between two integers in the code.

solved C program not printing out correct output