Loops


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int k = 0, L = 0;
    while (k < 2)
    {
    Read: k++;
    while (L < 3)
    {
    printf("Interveiw Mania");
    goto Read;
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    "Interview Mania" is printed infinite time


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int n = 0, L = 0;
    while (Read: n < 25)
    {
    n++;
    while (L < 15)
    {
    printf("Ajit");
    goto Read;
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Compilation Error

    main.c: In function ‘main’:
    main.c:5:16: error: ‘Read’ undeclared (first use in this function); did you mean ‘fread’?
    while (Read: n < 25)
    ^~~~
    fread
    main.c:5:16: note: each undeclared identifier is reported only once for each function it appears in
    main.c:5:20: error: expected ‘)’ before ‘:’ token
    while (Read: n < 25)
    ^
    main.c:11:17: error: label ‘Read’ used but not defined
    goto Read;



  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int n = 0, m = 0;
    Read: while (n < 3)
    {
    n++;
    while (m < 10)
    {
    printf("Sumi...\n");
    goto Read;
    }
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Sumi...
    Sumi...
    Sumi..


  1. Which of the following statement are correct about the program given below?
    #include <stdio.h>
    int main ( )
    {
    char ch;
    while (ch = 0; ch <= 255; ch++)
    printf ("ASCII value %d Character %c\n", ch, ch);
    return 0;
    }









  1. View Hint View Answer Discuss in Forum

    The program reports an error as while loop cannot take the form of a for loop.

    Correct Option: D

    The program reports an error as while loop cannot take the form of a for loop.



  1. Which of then following is the correct output for the program given below?
    #include <stdio.h>
    int main()
    {
    int k = 5;
    while ( k++ != 5)
    printf ("%d", ++k);
    printf ("\n");
    return 0;
    }









  1. View Hint View Answer Discuss in Forum

    Condition in while loop is false.

    Correct Option: D

    Condition in while loop is false.