C++ Program to Print Half Pyramid of Numbers

In this program, you'll learn to print half pyramid of numbers.



Source Code
#include <iostream>
using namespace std;

int main()
{
    int i,j;

    for (i=0; i<5; i++)
    {
        for (j=0; j<=i; j++)
        {
            cout<< i+1 << " ";
        }
        cout<< "\n";
    }
    return 0;
}
Output
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5