§The statement is executed repeatedly as
long as the expression is true (non zero)
The cycle continues until expression
becomes zero, at which point execution resumes after statement
§If the test expression in a while loop is
false initially, the while loop will never be executed
int i = 1,
sum = 0;
while (i
<= 10)
{
sum = sum + i;
i= i + 1;
}
printf(“Sum
= %d\n”, sum);
No comments:
Post a Comment