this question has answer here:
every time run program different , weird results. why that?
#include <stdio.h> int main(void) { int = 5, b = 2; printf("%.2f", a/b); return 0; }
printf("%.2f", a/b);
the output of division again of type int
, not float
.
- you using wrong format specifier lead undefined behavior.
- you need have variables of type float perform operation doing.
the right format specifier print out int
%d
Comments
Post a Comment