The output is "1,4 " because 'c' is a char and takes 1 byte,and 100 is an integer -- takes 4 bytes
Amit
Dec 29th, 2005
natasha..pls check ur ans..what have u given the reply..it is totally wrong
Pawan
Jan 2nd, 2006
The answer is 2,2 coz sizeof return the memory occupied and "c" uses 1 byte to store character 'c' and the other byte to store NULL to indicate the end of string. 100 being stored as an interger would take 2 bytes
Natasha, In c int takes only 2 byte.while in java int takes 4 byte.so answer is 1,2
Chandra Shekhar Chaubey
Feb 3rd, 2006
Its depend upon the compiler.
if compiler is treating your integer as a 2 byte then ans will be 2,2 and if
compiler is treating your interger as 4 byte then answer will be 4,4
paulson paul chambakottukudyil
Apr 19th, 2006
The answer will be compiler dependent.
If you are using ANSI C or Turbo c, the answer would be 2,2, because 'c' is taken as 98. size of 98 will be 2, same as that of 100. 'c' will not be considered as a string and hence there is no NULL or '\0'. There will be a '\0' only if we write "c".
paulson paul chambakottukudyil
Apr 19th, 2006
Answer is compiler dependent.
If you are using ANSI C or Turbo C, the output will be 2,2.
If the compiler is MS Visual studio, the output will be 1,4.
'c' is not considered as a string and so, there is no NULL or '\0'. The size comes as 2 because it is taken as 98, an integer. so sizeof('c') is equalent to sizeof(98) and output will be 2, same as that of sizeof(100).
In MS Visual Studio, size of the integer is 4 bytes and hence the answer 4.
Main(){ printf("%d, %d", sizeof('c'), sizeof(100));}
B) 2, 100
C) 2, 2
D) 4, 4