Sail E0 Webinar
Question


Point out the error, if any in the while loop.


#include<stdio.h>
int main()
{
int i=1;
while()
{
printf("%d\n", i++);
if(i>10)
break;
}
return 0;
}
Options:
A .  There should be a condition in the while loop
B .  There should be at least a semicolon in the while
C .  The while loop should be replaced with for loop.
D .  No error
Answer: Option A

The while() loop must have conditional expression or it shows "Expression syntax" error.

Example: while(i > 10){ ... }



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers