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

CSE MCQs :: C-MCQs

  1. What is the output of this C code?


        int main()

        {

           int i = 0;

            do {

                i++;

                printf("In while loop\n");

            } while (i < 3);

        }

  2. A.
    In while loop
     In while loop
     In while loop
    B.
    In while loop
     In while loop
    C.
    Depends on the compiler
    D.
    Compile time error

  3. How many times i value is checked in the below code?


        int main()

        {

            int i = 0;

            do {

                i++;

                printf("in while loop\n");

            } while (i < 3);

        }

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

  5. How many times i value is checked in the below code?


      int main()

        {

            int i = 0;

            while (i < 3)

                i++;

            printf("In while loop\n");

        }

  6. A.
    2
    B.
    3
    C.
    4
    D.
    1

  7. What is the output of this C code?


        void main()

        {

            int i = 2;

            do

            {

                printf("Hi");

            } while (i < 2)

        }

  8. A.
    Compile time error
    B.
    Hi Hi
    C.
    Hi
    D.
    Varies

  9. What is the output of this C code?


        void main()

        {

            int i = 0;

            while (++i)

            {

                printf("H");

            }

        }

  10. A.
    H
    B.
    H is printed infinite times
    C.
    Compile time error
    D.
    Varies

  11. What is the output of this C code?


        void main()

        {

            int i = 0;

            do

            {

                printf("Hello");

            } while (i != 0);

        }

  12. A.
    Nothing
    B.
    H is printed infinite times
    C.
    Hello
    D.
    Run time error

  13. What is the output of this C code?


        void main()

        {

            char *str = "";

            do

            {

                printf("hello");

            } while (str);

        }

  14. A.
    Nothing
    B.
    Run time error
    C.
    Varies
    D.
    Hello is printed infinite times

  15. What is the output of this C code?


       void main()

        {

            int i = 0;

            while (i < 10)

           {

                i++;

                printf("hi\n");

            } while (i < 8)

           i++;

            printf("hello\n");

        }

  16. A.
    Hi is printed 8 times, hello 7 times and then hi 2 times
    B.
    Hi is printed 10 times, hello 7 times
    C.
    Hi is printed once, hello 7 times
    D.
    Hi is printed once, hello 7 times and then hi 2 times

  17. Example of iteration in C.
  18. A.
    for
    B.
    while
    C.
    do-while
    D.
    All of the mentioned

  19. Number of times while loop condition is tested is, i is initialized to 0 in both case.

          while (i < n)

              i++;

         -------------

         do

              i++;

         while (i <= n);

  20. A.
    n, n
    B.
    n, n+1
    C.
    n+1, n
    D.
    n+1, n+1