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

CSE MCQs :: C-MCQs

  1. What is the output of code given below?


        int main()

        {

            printf("%d ", 1);

            l1:l2:

            printf("%d ", 2);

            printf("%d\n", 3);

        }

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

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What is the output of code given below?


        int main()

        {

           printf("%d ", 1);

            goto l1;

            printf("%d ", 2);

        }

        void foo()

        {

            l1 : printf("3 ", 3);

        }

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

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What is output of code given below?


        int main()

        {

            int i = 0, j = 0;

           while (i < 2)

            {

                l1 : i++;

                while (j < 3)

                {

                    printf("Loop\n");

                    goto l1;

                }

            }

        }

  6. A.
    Loop Loop
    B.
    Compilation error
    C.
    Loop  Loop  Loop  Loop
    D.
    Infinite Loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the output of code given below?


        int main()

        {

            int i = 0, j = 0;

            while (l1: i < 2)

            {

                i++;

                while (j < 3)

                {

                    printf("loop\n");

                    goto l1;

                }

            }

        }

  8. A.
    loop  loop
    B.
    Compilation error
    C.
    loop  loop  loop  loop
    D.
    Infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


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


        int main()

        {

            int i = 0, j = 0;

            l1: while (i < 2)

            {

                i++;

                while (j < 3)

                {

                    printf("loop\n");

                    goto l1;

                }

            }

        }

  10. A.
    loop  loop
    B.
    compilation error
    C.
    loop  loop  loop  loop
    D.
    infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. The output of the code below is?


        void main()

        {

            int i = 0;

            if (i == 0)

            {

                goto label;

            }

            label: printf("Hello");

        }

  12. A.
    Nothing
    B.
    Error
    C.
    Infinite Hello
    D.
    Hello

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the output of this C code?


        void main()

        {

            int i = 5, k;

            if (i == 0)

                goto label;

               label: printf("%d", i);

                printf("Hey");

        }

  14. A.
    5
    B.
    Hey
    C.
    5 Hey
    D.
    Nothing

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. goto can be used to jump from main to within a function?
  16. A.
    true
    B.
    false
    C.
    depends
    D.
    Varies

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the output of this C code?


        int main()

        {

            printf("%d ", 1);

            goto l1;

            printf("%d ", 2);

            l1:goto l2;

            printf("%d ", 3);

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

       }

  18. A.
    1 4
    B.
    Compile time error
    C.
    1 2 4
    D.
    1 3 4

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of this C code?


        int main()

        {

            printf("%d ", 1);

            l1:l2:

            printf("%d ", 2);

            printf("%d\n", 3);

        }

  20. A.
    Compile time error
    B.
    1 2 3
    C.
    1 2
    D.
    1 3

    View Answer

    Workspace

    Discuss Discuss in Forum