C++ Program to Print a Simple Number Pattern

Write a C++ program to print a simple number pattern using for loop.

#include<iostream>
using namespace std;

int main()
{
	int i, j, rows;
     
    cout << "Enter Simple Number Pattern Rows = ";
    cin >> rows;

    cout << "Simple Number Pattern\n"; 

    for(i = 1; i <= rows; i++)
    {
    	for(j = 1; j <= i; j++)
		{
            cout << j << " ";
        }
        cout << "\n";
    }		
 	return 0;
}
C++ Program to Print a Simple Number Pattern

This C++ example example displays the numbers in the right angled triangle using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int i = 1, j, rows;
     
    cout << "Enter Simple Number Pattern Rows = ";
    cin >> rows;

    cout << "Simple Number Pattern\n"; 

    while(i <= rows)
    {
        j = 1; 
    	while(j <= i)
		{
            cout << j << " ";
            j++;
        }
        cout << "\n";
        i++;
    }		
 	return 0;
}
Enter Simple Number Pattern Rows = 14
Simple Number Pattern
1 
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 
1 2 3 4 5 6 
1 2 3 4 5 6 7 
1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 10 
1 2 3 4 5 6 7 8 9 10 11 
1 2 3 4 5 6 7 8 9 10 11 12 
1 2 3 4 5 6 7 8 9 10 11 12 13 
1 2 3 4 5 6 7 8 9 10 11 12 13 14