C program for finding roots of a quadratic equation
Why this C program returns an output even if I enter a character when its made to accept float type value, it also doesnt ask for the third value then? Also, why this value?
I was expecting an error but the program executed successfully and even returned a value, now I’m confused
Please add your code to the question as text.
I bet you’re using
scanf()
without checking to see if it succeeded or not.The error message doesn’t match the code. The error message has
%c%c%c
but the code has%f%f%f
@Shawn
%c
will always succeed unless it reaches EOF, so checking the return value won’t help.Using an incorrect format code in
scanf()
orprintf()
causes undefined behavior. It doesn’t necessarily cause a visible error.Show 2 more comments