GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  TCS  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 61 of 87    Print  
a=0;
while(a<5)
printf("%d\n", a++);
How many times does the loop occurs?

A. infinite
B. 5
C. 4
D. 6


  
Total Answers and Comments: 6 Last Update: June 13, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 10, 2006 11:12:21   #1  
Vikram        

RE: a=0;while(a<5)printf("%dn"...
The correct ans is option B. and the value will be 5.
 
Is this answer useful? Yes | No
August 11, 2006 04:29:01   #2  
ranjith        

RE: a=0;while(a<5)printf("%dn"...
a.infinite
 
Is this answer useful? Yes | No
February 14, 2007 12:07:11   #3  
Satya        

RE: a=0;while(a<5)printf("%dn"...
It should be 6 times...Here is the output...012345a++ --> First prints the value then adds.
 
Is this answer useful? Yes | No
September 25, 2007 17:58:03   #4  
Nishi Rathore        

RE: a=0;while(a<5)printf("%dn"...
the ans is B bcoz the loop will work for values of a (0 1 2 3 4)
 
Is this answer useful? Yes | No
June 04, 2008 01:31:34   #5  
anu1985 Member Since: May 2008   Contribution: 11    

RE: a=0;while(a<5)printf("%dn", a++);How many times does the loop occurs?A. infiniteB. 5C. 4D. 6
the loop will run for 5 times
 
Is this answer useful? Yes | No
June 13, 2008 11:46:46   #6  
chandradeepika Member Since: May 2008   Contribution: 36    

RE: a=0;while(a<5)printf("%dn", a++);How many times does the loop occurs?A. infiniteB. 5C. 4D. 6
ans:A)infinite.
Becoz a is initialized to 0 and it is not incremented.so the condition wont become false and so it will execute for infinite times.

 
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