GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  TCS  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 85 of 87    Print  
what is the output of following program?
#include
void main()
{
printf("%d%d",sizeof(NULL),sizeof(" "));
}

  
Total Answers and Comments: 10 Last Update: November 19, 2009     Asked by: pavankishore 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: radhika
 

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



Above answer was rated as good by the following members:
hydsarema
November 29, 2006 10:10:07   #1  
rohit khanna        

RE: what is the output of following program?#inc...
an error will apper while compiling the program that function printf should have prototype
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
February 02, 2007 01:22:30   #2  
Arwa Patel        

RE: what is the output of following program?#inc...
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

 
Is this answer useful? Yes | No
February 15, 2007 08:42:27   #3  
winny gupta Member Since: February 2007   Contribution: 8    

RE: what is the output of following program?#inc...
Since the file name ie stdio.h not included hence will give an error..
 
Is this answer useful? Yes | No
March 23, 2007 04:59:15   #4  
radhika        

RE: what is the output of following program?#inc...

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


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 02, 2008 04:46:01   #5  
SpandanaMohan Member Since: January 2008   Contribution: 12    

RE: what is the output of following program?#includevoid main(){printf("%d%d",sizeof(NULL),sizeof(" "));}
Error..The printf stmt shld hav a prototype...
 
Is this answer useful? Yes | No
August 26, 2008 05:55:14   #6  
mraghu Member Since: August 2008   Contribution: 1    

RE: what is the output of following program?#include void main(){printf("%d%d",sizeof(NULL),sizeof(" "));}
Error
 
Is this answer useful? Yes | No
September 06, 2008 12:16:12   #7  
abhishek125 Member Since: June 2008   Contribution: 1    

RE: what is the output of following program?#includevoid main(){printf("%d%d",sizeof(NULL),sizeof(" "));}
it will print : 2 2
 
Is this answer useful? Yes | No
November 16, 2008 10:10:24   #8  
joejan Member Since: November 2008   Contribution: 1    

RE: what is the output of following program?#includevoid main(){printf("%d%d",sizeof(NULL),sizeof(" "));}
It is 2 2. If the there are 3 spaces in between the brackets output would be 2 3
 
Is this answer useful? Yes | No
October 09, 2009 09:28:39   #9  
nirmal1989 Member Since: October 2009   Contribution: 1    

RE: what is the output of following program?#includevoid main(){printf("%d%d",sizeof(NULL),sizeof(" "));}
If <stdio.h> is included it will print 42 which means sizeof null is 4 and that of char is 2.
 
Is this answer useful? Yes | No
November 19, 2009 21:24:53   #10  
daniel.raj.n Member Since: May 2008   Contribution: 1    

RE: what is the output of following program?#includevoid main(){printf("%d%d",sizeof(NULL),sizeof(" "));}
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.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape