Ashima wants to print a pattern which includes checking and changing a variables value iteratively She decides to use a loop/condition ...



Ashima wants to print a pattern which includes checking and changing a variables value iteratively She decides to use a loop/condition Which of the following options should she use such that the body of the loop/condition is executed at least once whether the variable satisfies the entering condition or not ?

A. For loop

B. While loop

C. Do-while loop

D. Switch case

E. None of these

Answer : C. Do-while loop


Explanation:

Do While Loop :

  • Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming checks its condition at the bottom of the loop.
  • A do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time.

Syntax for Do While Loop :

do {
     statement(s);
}    while( condition );


Related Searches to Ashima wants to print a pattern which includes checking and changing a variables value iteratively She decides to use a loop/condition...