top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the significance of semicolon just after while statement in C why loop does not run?

–1 vote
597 views
while(i<10);
{
  i++;
  printf("%d,\n", i);
}

Loop does not run for 10 iterations, what is the error?

posted Jun 20, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

If you put semicolon just after for and while loop statement; it consider there is no associated statement(s) and it does nothing it becomes a simple conditional statement nothing else.

answer Jun 21, 2016 by Harshita
0 votes

Consider If the value of i=0, in while(i<10); it keeps on checking condition will never fails . so Loop is continuously running .

answer Jun 22, 2016 by Mohan Raj N
Similar Questions
+2 votes
for (a=1; a&lt;=100; a++)

printf (&quot;%d\n&quot;, a * a);
+3 votes

While(0) means dont enter into it, but why you want to have while(0) in c code. Any suggestion.

Asked in the interview today.

...