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

C Do While Looping MCQ


Q1) Choose a right C Statement.
  1. Loops or Repetition block executes a group of statements repeatedly.
  2. Loop is usually executed as long as a condition is met.
  3. Loops usually take advantage of Loop Counter
  4. All the above.

Answer:- (D).
Explanations :None.
Q2Loops in C Language are implemented using.?
  1. While Block
  2. For Block
  3. Do While Block
  4. All the above

Answer:- (D).
Explanations :None.
Q3) Which loop is faster in C Language, for, while or Do While.?
  1. for
  2. while
  3. do while
  4. All work at same speed

Answer:- (D).
Explanations :None.
Q4) Choose correct C while loop syntax.
  1. while(condition)
    {
    //statements
    }
  2. {
    //statements
    }while(condition)
  3. while(condition);
    {
    //statements
    }
  4. while()
    {
    if(condition)
    {
    //statements
    }
    }

Answer:- (A).
Explanations :None.
Q5) Choose a correct C for loop syntax.
  1. for(initalization; condition;
    incrementoperation)
    {
    //statements
    }
  2. for(declaration; condition; incrementoperation)
    {
    //statements
    }
  3. for(declaration; incrementoperation; condition)
    {
    //statements
    }
  4. for(initalization; condition;
    incrementoperation;)
    {
    //statements
    }s

Answer:- (A).
Explanations :increment or decrement operation at third place.
Q6) Choose a correct C do while syntax.
  1. dowhile(condition)
    {
    //statements
    }
  2. do while(condition)
    {
    //statements
    }
  3. do
    {
    //statements
    }while(condition)
  4. do
    {
    //statements
    }while(condition);

Answer:- (D).
Explanations :Semicolon after while(condition) is a must.
Q7) What is the output of C Program.?
int main()
{
    while(true)    
    {
        printf("RABBIT");
        break;
    }
    
    return 0;
}
  1. RABBIT
  2. RABBIT is printed unlimited number of times.
  3. No output
  4. Compiler error.

Answer:- (D).
Explanations :while(TRUE) or while(true) does not work. true is not a keyword.
Q8) What is the output of C Program.?
int main()
{
    int a=5;
    
    while(a==5)    
    {
        printf("RABBIT");
        break;
    }

    return 0;
}}
  1. RABBIT is printed unlimited number of times
  2. RABBIT
  3. Compiler error
  4. None of the above.

Answer:- (B).
Explanations :If there is no BREAK statement, while loop runs continuously util the computer hangs. BREAK causes the loop to break once and the statement below the while if any will be executed.
Q9) What is the output of C Program.?
int main()
{
    int a=5;
    
    while(a=123)    
    {
        printf("RABBIT\n");
        break;
    }
    printf("GREEN");
    
    return 0;
}
  1. GREEN
  2. RABBIT GREEN
  3. RABBIT is printed unlimited number of times.
  4. Compiler error.

Answer:- (B).
Explanations :while(a=123) = while(123) = while(Non Zero Number). So while is executed. BREAK breaks the loop immediately. Without break statement, while loop runs infinite number of times.
Q10) What is the output of C Program.?
int main()
{
    int a=5;
    
    while(a >= 3);
    {
        printf("RABBIT\n");
        break;
    }
    printf("GREEN");
    
    return 0;
}
  1. GREEN
  2. RABBIT GREEN
  3. RABBIT is printed infinite times/li>
  4. None of the above

Answer:- (D).
Explanations :Notice a semicon(;) after while condition. It makes the printf and break statement blocks isolate.

while(a >= 3)
{
;//infinite loop
}
{
printf("RABBIT\n");
break;
}