Sail E0 Webinar

MCQs

Total Questions : 97 | Page 2 of 10 pages
Question 11. What is the output of this C code?

    void main()

    {

        char *str = "";

        do

        {

            printf("hello");

        } while (str);

    }

  1.    Nothing
  2.    Run time error
  3.    Varies
  4.    Hello is printed infinite times
 Discuss Question
Answer: Option D. -> Hello is printed infinite times


none


Question 12. What is the output of this C code?

    int main()

    {

        int i = 0;

        while (i = 0)

            printf("True\n");

        printf("False\n");

    }

  1.    True (infinite time)
  2.    True (1 time) False
  3.    False
  4.    Compiler dependent
 Discuss Question
Answer: Option C. -> False


none


Question 13. 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

  1.    n, n
  2.    n, n+1
  3.    n+1, n
  4.    n+1, n+1
 Discuss Question
Answer: Option D. -> n+1, n+1


none


Question 14. Example of iteration in C.
  1.    for
  2.    while
  3.    do-while
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned


none


Question 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");

    }

  1.    Hi is printed 8 times, hello 7 times and then hi 2 times
  2.    Hi is printed 10 times, hello 7 times
  3.    Hi is printed once, hello 7 times
  4.    Hi is printed once, hello 7 times and then hi 2 times
 Discuss Question
Answer: Option D. -> Hi is printed once, hello 7 times and then hi 2 times


none


Question 16. What is the output of this C code?

   int main()

    {

        int i = 0;

        for (; ; ;)

            printf("In for loop\n");

            printf("After loop\n");

    }

  1.    Compile time error
  2.    Infinite loop
  3.    After loop
  4.    Undefined behaviour
 Discuss Question
Answer: Option A. -> Compile time error


none


Question 17. What is the output of this C code?

    int main()

    {

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

            printf("In for loop\n");

    }

  1.    Compile time error
  2.    In for loop
  3.    Depends on the standard compiler implements
  4.    Depends on the compiler
 Discuss Question
Answer: Option C. -> Depends on the standard compiler implements


none


Question 18. 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");

    }

  1.    In for loop after loop
  2.    After loop
  3.    Compile time error
  4.    Undefined behaviour
 Discuss Question
Answer: Option A. -> In for loop after loop


none


Question 19. 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;

    }

  1.    After loop
  2.    In for loop after loop
  3.    Compile time error
  4.    Infinite loop
 Discuss Question
Answer: Option A. -> After loop


none


Question 20. 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");

    }

  1.    In for loop after loop
  2.    Compile time error
  3.    Infinite loop
  4.    Depends on the value of NULL
 Discuss Question
Answer: Option B. -> Compile time error


none


Latest Videos

Latest Test Papers