/* */ Click to Join Live Class with Shankar sir Call 9798158723

C While Looping MCQ


Q1. What will be the output of the following C code?
#include 
    int main()
    {
        while ()
            printf("In while loop ");
        printf("After loop\n");
    }
  1. In while loop after loop
  2. After loop
  3. Compile time error
  4. Infinite loop

Answer:- (C).
Explanations :None.
Q2. What will be the output of the following C code?
#include 
    int main()
    {
        do
            printf("In while loop ");
        while (0);
            printf("After loop\n");
    }}
  1. In while loop
  2. In while loop)
  3. After loop
  4. Infinite loop

Answer:- (B).
Explanations :None.
Q3. What will be the output of the following C code?
#include 
    int main()
    {
        int i = 0;
        do {
            i++;
            printf("In while loop\n");
        } while (i < 3);
    }
  1. In while loop
  2. Depends on the compiler
  3. loop
  4. Compile time error

Answer:- (A).
Explanations :None.
Q4. How many times i value is checked in the following C code?
#include 
    int main()
    {
        int i = 0;
        do {
            i++;
            printf("in while loop\n");
        } while (i < 3);
    }
  1. 2
  2. 3
  3. 4
  4. 1

Answer:- (B).
Explanations :None.
Q5. How many times i value is checked in the following C code?
 #include 
    int main()
    {
        int i = 0;
        while (i < 3)
            i++;
        printf("In while loop\n");
    } 
  1. 2
  2. 3
  3. 4
  4. 1

Answer:- (C).
Explanations :None
Q6. What will be the output of the following C code?
#include 
    void main()
    {
        int i = 2;
        do
        {
            printf("Hi");
        } while (i < 2)
    }
  1. Compile time error
  2. Hi Hi
  3. Hi
  4. Varies

Answer:- (A).
Explanations :None
Q7. What will be the output of the following C code?
#include 
    void main()
    {
        int i = 0;
        while (++i)
        {
            printf("H");
        }
    }
  1. H
  2. H is printed infinite times
  3. Compile time error
  4. Varies

Answer:- (B).
Explanations :None
Q8. What will be the output of the following C code?
#include 
    void main()
    {
        int i = 0;
        do
        {
            printf("Hello");
        } while (i != 0);
    }
  1. Nothing
  2. H is printed infinite times
  3. Hello
  4. Run time error

Answer:- (C).
Explanations :None
Q9. What will be the output of the following C code?
#include 
    void main()
    {
        char *str = "";
        do
        {
            printf("hello");
        } while (str);
    }
  1. Nothing
  2. Run time error
  3. Varies
  4. Hello is printed infinite times

Answer:- (D).
Explanations :None
Q10. What will be the output of the following C code?
#include 
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

Answer:- (D).
Explanations :None