Control Instructions

Q1: 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;
}

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

ANS:A -

There should be a condition in the while loop

The while() loop must have conditional expression or it shows 'Expression syntax' error. Example: while(i > 10){ ... }



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.