Advertisement
Caminhoneiro

Counting program

Apr 13th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. // Game.cpp : define o ponto de entrada para o aplicativo do console.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7.  
  8. using namespace std;
  9. int main()
  10. {
  11.     cout << "Counting forward:\n";
  12.     for (int i = 0; i < 10; ++i)
  13.     {
  14.         cout << i << " ";
  15.     }
  16.     cout << "\n\nCounting backward:\n";
  17.     for (int i = 9; i >= 0; --i)
  18.     {
  19.         cout << i << " ";
  20.     }
  21.     cout << "\n\nCounting by fives:\n";
  22.     for (int i = 0; i <= 50; i += 5)
  23.     {
  24.         cout << i << " ";
  25.     }
  26.     cout << "\n\nCounting with null statements:\n";
  27.     int count = 0;
  28.     for (; count < 10; )
  29.     {
  30.         cout << count << " ";
  31.         ++count;
  32.     }
  33.     cout << "\n\nCounting with nested for loops:\n";
  34.     const int ROWS = 5;
  35.     const int COLUMNS = 3;
  36.     for (int i = 0; i < ROWS; ++i)
  37.     {
  38.         for (int j = 0; j < COLUMNS; ++j)
  39.         {
  40.             cout << i << "," << j << " ";
  41.         }
  42.         cout << endl;
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement