Welcome Guest | Sign in | Register
Loops - Discussion Page For Q.10444 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Loops > Questions and Answers

Q: How many times the below loop will get executed?
main()
{
int i;
for(i=9;i;i=i-2)
{
printf("\n%d",i);
}
}
A. 5 B. 6
C. Compilation Error D. Infinite

Answer and Explanation

Answer:Infinite

Explanation:
Above loop will iterate till i have non zero value. Initial value of i is 9 and it get decremented by 2 in every iteration ( 9, 7, 5, 3, 1, -1, -3 â?¦.). Value of i will never become 0 and loop will run infinitely.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.