Loops


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int k = 0;
    for (fun(); k == 1; k = 2)
    printf("Executed in loop\n");
    printf("Executed After loop\n");
    }
    int fun()
    {
    return 1;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Executed After loop


  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int *ptr = NULL;
    for (fun(); ptr; ptr = 0)
    printf("Executed in loop\n");
    printf("Executed After loop\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Compilation Error



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    for (int k = 0; k < 1; k++)
    printf("Executed In for loop\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Depends on the standard compiler implements


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    while ()
    printf("Executed In while loop ");
    printf("Executed After loop\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Compilation Error

    main.c: In function ‘main’:
    main.c:4:16: error: expected expression before ‘)’ token
    while ()



  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    printf("Ajit ");
    Label1: Label2:
    printf("Sumi ");
    printf("Abhay ");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Ajit Sumi Abhay