Consider the following program:
main()
{
int age = 10;
int adult_age = 18;
while(age++ <= adult_age);
printf(\"%d\" , age);
} [/sourcecode]
What age will be printed at the end of execution?
(A) 11
(B) 18
(C) 19
(D) 20
Answer: (D)
Explanation: Given \’while\’ loop will be executed till \’age > adult_age\’ condition not satisfied. So,\’while\’ loop will be terminate when for \’age = 20\’.
For each loop \’age\’ will be increment by 1.
So, option (D) is correct.
Quiz of this Question
Share your thoughts in the comments
Please Login to comment...