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

CSE MCQs :: C-MCQs

  1. What is the output of this C code?


        int main()

        {

            printf("%d ", 1);

            goto l1;

            printf("%d ", 2);

        }

        void foo()

        {

            l1: printf("3 ", 3);

        }

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

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What is the output of this C code?


        int main()

        {

            int i = 0, j = 0;

            while (i < 2)

            {

                l1: i++;

                while (j < 3)

                {

                    printf("loop\n");

                    goto l1;

                }

            }

       }

  4. A.
    loop loop
    B.
    Compile time error
    C.
    loop loop loop loop
    D.
    Infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What is the output of this C code?


        int main()

        {

            int i = 0, j = 0;

            while (l1: i < 2)

            {

                i++;

                while (j < 3)

                {

                    printf("loop\n");

                    goto l1;

               }

            }

       }

  6. A.
    loop loop
    B.
    Compile time error
    C.
    loop loop loop loop
    D.
    Infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the output of this C code?


        int main()

        {

            int i = 0, j = 0;

            l1: while (i < 2)

                {

                    i++;

                    while (j < 3)

                    {

                        printf("loop\n");

                        goto l1;

                    }

                }

       }

  8. A.
    loop loop
    B.
    Compile time error
    C.
    loop loop loop loop
    D.
    Infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. The output of the code below is?


        void main()

        {

            int x = 5;

            if (x < 1)

                printf("hello");

            if (x == 5)

                printf("hi");

            else

                printf("no");

        }

  10. A.
    hi
    B.
    hello
    C.
    no
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. The output of the code below is?


        int x;

        void main()

        {

            if (x)

                printf("hi");

            else

                printf("how are u");

        }

  12. A.
    hi
    B.
    how are you
    C.
    Compile time error
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Comment on the following code below?


        void main()

        {

           int x = 5;

            if (true);

                printf("hello");

        }

  14. A.
    It will display hello
    B.
    It will throw an error
    C.
    Nothing will be displayed
    D.
    Compiler dependent

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. The output of the code below is?

        void main()

        {

            int x = 0;

            if (x == 0)

                printf("hi");

            else

               printf("how are u");

                printf("hello");

        }

  16. A.
    hi
    B.
    how are you
    C.
    hello
    D.
    hihello

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. The output of the code below is?


        void main()

        {

            int x = 5;

            if (x < 1);

                printf("Hello");

        }

  18. A.
    Nothing
    B.
    Run time error
    C.
    Hello
    D.
    Varies

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. The output of the code below is(when 1 is entered)?


        void main()

        {

            double ch;

            printf("enter a value btw 1 to 2:");

            scanf("%lf", &ch);

            switch (ch)

            {

            case 1:

                printf("1");

                break;

            case 2:

                printf("2");

                break;

            }

        }

  20. A.
    compile time error
    B.
    1
    C.
    2
    D.
    Varies

    View Answer

    Workspace

    Discuss Discuss in Forum