0
Why am I getting 0 as the output? Shouldn't the output be 40?
#include <studio.h> int main() { int volume; int length = 5; int width = 8; volume = length * width; printf("%f", volume); return 0; }
6 Answers
+ 3
printf("%d \n", volume); /* 40 */
+ 2
can only be used:
d decimal
c character
s string
f float
e scientific notation
x hexadecimal
+ 1
%f for digits with floating point.
You have integer type variables. At the output you send to the console the value in the floating point. Therefore, it turns out 0.000
0
Then you show me the right approach.
0
Won't printf("%i, volume); would do the work? @Aidos
0
it would if you quote close the %i
printf("%i ", volume);