Home » C Programming » Loops » Question
  1. In the program given below, point out the error, if any, in the while loop.
    #include <studio.h>
    int main()
    {
    int k = 5;
    while ( )
    {
    printf("%d\n", k++);
    if (k >10)
    break;
    }
    return 0;
    }
    1. There should be a condition in the while loop.
    2. There should be at least a semicolon in the while( ).
    3. The while loop should be replaced by a for loop.
    4. No error
Correct Option: A

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



Your comments will be displayed only after manual approval.