Home / CSE MCQs / C-MCQs :: Control Flow Statements

CSE MCQs :: C-MCQs

  1. What is the output of this C code?


        void main()

        {

            int k = 0;

            for (k < 3; k++)

            printf("Hello");

        }

  2. A.
    Compile time error
    B.
    Hello is printed thrice
    C.
    Nothing
    D.
    Varies

  3. What is the output of this C code?


        void main()

        {

            double k = 0;

            for (k = 0.0; k < 3.0; k++)

                printf("Hello");

        }

  4. A.
    Run time error
    B.
    Hello is printed thrice
    C.
    Hello is printed twice
    D.
    Hello is printed infinitely

  5. What is the output of this C code?


       void main()

        {

            double k = 0;

            for (k = 0.0; k < 3.0; k++);

                printf("%lf", k);

       }

  6. A.
    2.000000
    B.
    4.000000
    C.
    3.000000
    D.
    Run time error

  7. What is the output of this C code?


        void main()

        {

            int k;

            for (k = -3; k < -5; k++)

                printf("Hello");

        }

  8. A.
    Hello
    B.
    Infinite hello
    C.
    Run time error
    D.
    Nothing

  9. What is the output of this C code?


       int main()

        {

            int i = 0;

            for (; ; ;)

                printf("In for loop\n");

                printf("After loop\n");

        }

  10. A.
    Compile time error
    B.
    Infinite loop
    C.
    After loop
    D.
    Undefined behaviour

  11. What is the output of this C code?


        int main()

        {

           int i = 0;

            for (i++; i == 1; i = 2)

                printf("In for loop ");

                printf("After loop\n");

        }

  12. A.
    In for loop after loop
    B.
    After loop
    C.
    Compile time error
    D.
    Undefined behaviour

  13. What is the output of this C code?


       int main()

        {

            int i = 0;

            for (foo(); i == 1; i = 2)

                printf("In for loop\n");

                printf("After loop\n");

        }

        int foo()

        {

            return 1;

        }

  14. A.
    After loop
    B.
    In for loop after loop
    C.
    Compile time error
    D.
    Infinite loop

  15. What is the output of this C code?


        int main()

        {

            int *p = NULL;

            for (foo(); p; p = 0)

                printf("In for loop\n");

                printf("After loop\n");

        }

  16. A.
    In for loop after loop
    B.
    Compile time error
    C.
    Infinite loop
    D.
    Depends on the value of NULL

  17. What is the output of this C code?


        int main()

        {

           for (int i = 0;i < 1; i++)

                printf("In for loop\n");

        }

  18. A.
    Compile time error
    B.
    In for loop
    C.
    Depends on the standard compiler implements
    D.
    Depends on the compiler

  19. What is the output of the code given below?


       int main()

        {

           printf("%d ", 1);

            goto l1;

            printf("%d ", 2);

            l1:goto l2;

            printf("%d ", 3);

            l2:printf("%d ", 4);

       }

  20. A.
    1   4
    B.
    Compilation error
    C.
    1   2   4
    D.
    1   3   4