Author Topic: Triangle of Numbers  (Read 4297 times)

louiecerv

  • Moderator
  • User
  • *****
  • Posts: 85
Triangle of Numbers
« on: December 07, 2005, 01:14:06 AM »
Code: [Select]

#include <iostream>
using namespace std;

int main()
{
    int lines;
    cout << "NUMBER TRIANGLE" << endl <<endl;
    cout << "A program to display a triangle of numbers.\n";
    cout << "Number of lines to show: ";
    cin >> lines;
   
    int num = 1;
    for (int count = 0; count < lines; count++)
    {
        for (int row = 0; row <=count; row++)
        {
            cout << num;
            num++;
            if (num>9) num = 1;
        }
        cout << endl;
    }
   
    system("PAUSE");
    return 0;
}


Highlight:  Use of the nested for loop
Analyze. Design. Develop. Debug. Deploy. Maintain.