GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  TCS  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 46 of 87    Print  
What does the following function print?
func(int i)
{
if(i%2)return 0;
else return 1;
}
main()
{
int =3;
i=func(i);
i=func(i);
printf("%d",i);
}

A. 3
B. 1
C. 0
D. 2


  
Total Answers and Comments: 4 Last Update: June 02, 2007   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: Rohan
 

Ans is  ( B )

during first call  func returns 0  and in second call it returns 1



Above answer was rated as good by the following members:
nagarjunat
June 12, 2005 11:42:43   #1  
babu        

RE: What does the following function print?func(int i){if(i%2)return 0;else return 1;}main(){int =3;i=fu...
Ans. C
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
February 23, 2006 11:06:24   #2  
Rohan Member Since: November 2005   Contribution: 11    

RE: What does the following function print?func(i...

Ans is ( B )

during first call func returns 0 and in second call it returns 1


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
January 14, 2007 10:34:27   #3  
K.Rana Pratap        

RE: What does the following function print?func(i...

Answer is B

First it returns 0 so i value becomes zero. With the same value it enters if loop and becomes false....so it returns 1.


 
Is this answer useful? Yes | No
June 01, 2007 19:24:28   #4  
Sachin        

RE: What does the following function print?func(i...
The answer is zero and i do not see any second loop performing anything after the return statement.
 
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