+ 2
Why ans 0 in %d and not 10?
#include <stdio.h> int main() { float average; int total = 7; int count = 2; float he = 3.5; average = total / count*he; printf("%d and %f", average, average ); return 0; } //why ans 0 in %d and 10.500000 in %f https://code.sololearn.com/ccLMAC9JGh3f/?ref=app
5 Réponses
+ 3
Normally, when you work with floats and ints, the compiler does conversions automatically. However, with printf, the compiler does not know what type the function expects, so it leaves it as a float, when it should be an integer.
To solve this, you have to explicitly convert it to an int.
+ 2
Because the first parameter expects explicit type conversion integer to float 🤔
0
Because printf expects an integer, but you give it a float.
https://code.sololearn.com/cZk8Bd9oPFvP/?ref=app
0
Vlad Serbu can you elaborate I can't understand you.
0
Panpan quququ pananabanana yo to yo eh