Home » C Programming » Loops » Question
  1. On executing the following program how many times will the message "Thanks God" get printed?
    #include <stdio.h>
    int main ( )
    {
    int a;
    for(a = -1; a <= 10; a++)
    {
    if (a < 5)
    continue;
    else
    break;
    printf(" Thanks God\n");
    }
    return 0;
    }
    1. Infinite times
    2. 11 times
    3. 0 times
    4. Once
    5. 10 times
Correct Option: C

For value a less than 5 it won't print anything, and for any value greater than this loop will break. So thanks good will never be printed.



Your comments will be displayed only after manual approval.