C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - Point Out Errors (Q.No. 4)
4.
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: Option
Explanation:
The while() loop must have conditional expression or it shows "Expression syntax" error.
Example: while(i > 10){ ... }
Discussion:
2 comments Page 1 of 1.
Jack said:
8 years ago
Why does a while loop requires condition whereas for loop doesn't?
Ex: for(;;)
{
printf("%d\n", i++);
if(i>10)
break;
}
Please anyone help me.
Ex: for(;;)
{
printf("%d\n", i++);
if(i>10)
break;
}
Please anyone help me.
Sourav said:
8 years ago
I think D is the correct answer.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers