Main(){ printf("%d, %d", sizeof('c'), sizeof(100));}

A) 4, 100
B) 2, 100
C) 2, 2
D) 4, 4

Showing Answers 1 - 13 of 13 Answers

Amit

  • Dec 16th, 2005
 

2,2.since 'c' is treated as integer internally i.e ascii value of c so it is sizeof 2 bytes

  Was this answer useful?  Yes

Amit

  • Dec 29th, 2005
 

natasha..pls check ur ans..what have u given the reply..it is totally wrong

  Was this answer useful?  Yes

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

  Was this answer useful?  Yes

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".

  Was this answer useful?  Yes

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.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions