C++ examples for Statement:for
Declare for loop controlling variable inside for loop
#include <iostream> using namespace std; int main()//w ww . j ava 2 s . c om { int n = 0; // Get a number from the keyboard. cout << "Enter a number and press ENTER: "; cin >> n; for (int i = 1; i <= n; ++i){ // For i = 1 to n cout << i << " "; // Print i. } return 0; }