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;
}
Answer: A
Correct answer: There should be a condition in the while loop
Unlike for, a while requires a controlling expression - while() is a syntax error. The equivalent infinite loop is written while(1), or for(;;), where an omitted condition is defined to be true.
Please log in or register to report this question.