+ 1

We havent gave a numerical value in the given code but the output we get is in numerical form...How is it possible ?

#include <stdio.h> int main() { printf("int: %d \n", sizeof(int)); printf("float: %d \n", sizeof(float)); printf("double: %d \n", sizeof(double)); printf("char: %d \n", sizeof(char)); return 0; }

21st Aug 2018, 2:26 PM
Goutham Rajesh
Goutham Rajesh - avatar
3 Antworten
+ 3
Goutham Rajesh printf is there to print value and yes you have not used scanf for taking the input...so, behaviour is expected.. sizeof is the operator which is used and it returns size_t i.e. equivalent to int type value based on input... sizeof(int) let you know size for int datatype..
21st Aug 2018, 2:57 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Can u say simply
23rd Aug 2018, 5:32 AM
Goutham Rajesh
Goutham Rajesh - avatar
0
Goutham Rajesh printf prints value irrespective of your input..now question is from where it came as any hard coded value is not there.. it is came from sizeof(int) and all other same function... to verify, you declare a variable and assign value to sizeof(int)..you will see that it has some value which is getting printed.. feel free to ask in case of any query..
23rd Aug 2018, 8:36 AM
Ketan Lalcheta
Ketan Lalcheta - avatar