For loop combines all three of these steps together into a single statement. - C++ Statement

C++ examples for Statement:for

Description

For loop combines all three of these steps together into a single statement.

Demo Code

#include <iostream> 

int main() /*  w  w  w  .  j av  a  2  s . c o  m*/
{ 
    int number; 
    std::cout << "Enter a number: "; 
    std::cin >> number; 
     
    std::cout << "\nFirst 10 Multiples of " << number << "\n"; 
     
    for (int counter = 1; counter < 11; counter++) 
    { 
           std::cout << number * counter << " "; 
    } 
    std::cout << "\n"; 

    return 0; 
}

Result


Related Tutorials