Loops


  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int k = 0;
    do
    {
    k++;
    if (k == 2)
    continue;
    printf("Interview");
    } while (k < 2);
    printf(" Mania");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Interview Mania


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int k = 5;
    if (k == 5)
    {
    printf("Hello Interview Mania");
    break;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Compilation Error

    main.c: In function ‘main’:
    main.c:8:13: error: break statement not within loop or switch
    break;



  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int k = 2;
    if (k == 2)
    {
    printf("Hello Interview Mania");
    continue;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c: In function ‘main’:
    main.c:8:13: error: continue statement not within a loop
    continue;


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int k = 0;
    for (k = 0; k < 6; k++)
    if (k < 4)
    {
    printf("Interview Mania");
    break;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Interview Mania



  1. What will be the output of the following C code?
     #include <stdio.h>
    void main()
    {
    int k = 0;
    int L = 0;
    for (k = 0; k < 4; k++)
    {
    for (L = 0; L < 3; L++)
    {
    if (k > 1)
    continue;
    printf("Interview Mania\n");
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    "Interview Mania" is printed 6 times