enum {false,true};
int main()
{
int i=1;
do
{
printf("%d\n",i);
i++;
if(i < 15)
continue;
}while(false);
return 0;
}
Solution:
1
It prints 1 and quits.
Reason is continue statement brings/takes the execution to the beginning of the loop.
do while is nothing but while loop apart from the first iteration in which the
condition is not checked. Hence when continue is executed, execution to while
statement which returns false and hence quits the while loop.
Monday, October 26, 2009
Solutions to C Puzzles 3
Labels:
C Puzzles,
gowrikumar.com/c,
interview,
Solutions,
Tech Interview,
technical
Subscribe to:
Post Comments (Atom)
Whatever be the situation do-while loop always checks the 'while(condition)' in each iteration.
ReplyDelete