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++;

                if (i == 2)

                    continue;

                    printf("In while loop ");

            } while (i < 2);

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

        }

  2. A.
    In while loop 2
    B.
    In while loop In while loop 3
    C.
    In while loop 3
    D.
    Infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What is the output of this C code?


        int main()

        {

            int i = 0, j = 0;

            for (i; i < 2; i++){

                for (j = 0; j < 3; j++){

                    printf("1\n");

                    break;

                }

                printf("2\n");

            }

            printf("after loop\n");

        }

  4. A.
    1

         2

         after loop

    B.
    1

         after loop

    C.
    1

         2

         1

         2

         after loop

    D.
    1

         1

         2

         after loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What is the output of this C code?


        int main()

        {

            int i = 0;

            while (i < 2)

            {

                if (i == 1)

                    break;

                    i++;

                    if (i == 1)

                        continue;

                        printf("In while loop\n");

            }

            printf("After loop\n");

        }

  6. A.
    In while loop

         After loop

    B.
    After loop
    C.
    In while loop

         In while loop

         After loop

    D.
    In while loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the output of this C code?


        int main()

        {

            int i = 0;

            char c = 'a';

            while (i < 2){

                i++;

                switch (c) {

               case 'a':

                    printf("%c ", c);

                    break;

                    break;

                }

            }

            printf("after loop\n");

        }

  8. A.
    a after loop
    B.
    a a after loop
    C.
    after loop
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the output of this C code?


        int main()

        {

            printf("before continue ");

            continue;

            printf("after continue\n");

        }

  10. A.
    Before continue after continue
    B.
    Before continue
    C.
    after continue
    D.
    Compile time error

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. The following code 'for(;;)' represents an infinite loop. It can be terminated by.
  12. A.
    break
    B.
    exit(0)
    C.
    abort()
    D.
    All of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. The correct syntax for running two variable for loop simultaneously is.
  14. A.
    for (i = 0; i < n; i++)

          for (j = 0; j < n; j += 5)

    B.
    for (i = 0, j = 0;i < n, j < n; i++, j += 5)
    C.
    for (i = 0; i < n;i++){}

         for (j = 0; j < n;j += 5){}

    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3) ?
  16. A.
    Variable
    B.
    Function
    C.
    typedef
    D.
    macros

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the output of this C code?


        int main()

        {

            short i;

            for (i = 1; i >= 0; i++)

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

        }

  18. A.
    The control won't fall into the for loop
    B.
    Numbers will be displayed until the signed limit of short and throw a runtime error
    C.
    Numbers will be displayed until the signed limit of short and program will successfully terminate
    D.
    This program will get into an infinite loop and keep printing numbers with no errors

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of this C code?


       void main()

       {

           int k = 0;

            for (k)

                printf("Hello");

        }

  20. A.
    Compile time error
    B.
    hello
    C.
    varies
    D.
    nothing

    View Answer

    Workspace

    Discuss Discuss in Forum