A loop can test the condition at the end of the loop with the do-while statement. - C++ Statement

C++ examples for Statement:do while

Description

A loop can test the condition at the end of the loop with the do-while statement.

Demo Code

#include <iostream> 
 
int main() /*from  ww  w  .  j  a  v  a 2 s.c o  m*/
{ 
    int badger; 
    std::cout << "How many badgers? "; 
    std::cin >> badger; 
 
    do 
    { 
           std::cout << "Badger "; 
           badger--; 
    } while (badger > 0); 
     
    std::cout << "\n"; 
    return 0; 
}

Result


Related Tutorials