What is the output of following program?#includevoid main(){printf("%d%d",sizeof(NULL),sizeof(" "));}

This question is related to TCS Interview

Questions by pavankishore   answers by pavankishore

Showing Answers 1 - 43 of 43 Answers

rohit khanna

  • Nov 29th, 2006
 

an error will apper while compiling the program that function printf should have prototype

Arwa Patel

  • Feb 2nd, 2007
 

The answer is 44..
As the space is an empty character and one the compiler counts one more character for the Null character constant '/0' And the space that Null takes in memory is 4 bytes same as int, but this value depends on the Compiler that you use

  Was this answer useful?  Yes

radhika

  • Mar 23rd, 2007
 

the #include must be completed else its syntax error,
NULL have to be declared(stdio.h)
if <stdio.h> is included the result is 22

It depends on the memory model.

NULL will be defined as 0 or 0L ie as int or float. If the memory model is tiny, small or medium then sizeof(NULL) will be equated to sizeof(0) which is sizeof(int) = 2 bytes.
For other memory model itsvalue is 0L and so sizeof(0L) equals sizeof(long) =4 bytes.
and '' will be treated as a char and so its value is one byte.

  Was this answer useful?  Yes

linju26baby

  • Aug 29th, 2010
 

We need to include standard input output library first.ie, include stdio.h
After that, we can compile.. the final result will be 4 and 2.
The size of null is 4 and size of " " is 2.

  Was this answer useful?  Yes

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