Programming Code Center(PCC)
[CPP]

(PCC)::[How-to-write-CPP-Programs-To-Create-Pyramid-and-Pattern]::[cpp]

File Name : Create_Pyramid.cpp

//Example 1: Program to print half pyramid using *
//*
//* *
//* * *
//* * * *
//* * * * *
//Source Code

#include <iostream>
using namespace std;

int main()
{
    int rows;

    cout << "Enter number of rows: ";
    cin >> rows;

    for(int i = 1; i <= rows; ++i)
    {
        for(int j = 1; j <= i; ++j)
        {
            cout << "* ";
        }
        cout << "\n";
    }
    return 0;
}

//Example 2: Program to print half pyramid a using numbers
//1
//1 2
//1 2 3
//1 2 3 4
//1 2 3 4 5
//Source Code

#include <iostream>
using namespace std;

int main()
{
    int rows;

    cout << "Enter number of rows: ";
    cin >> rows;

    for(int i = 1; i <= rows; ++i)
    {
        for(int j = 1; j <= i; ++j)
        {
            cout << j << " ";
        }
        cout << "\n";
    }
    return 0;
}

//Example 3: Program to print half pyramid using alphabets
//A
//B B
//C C C
//D D D D
//E E E E E
//Source Code

#include <iostream>
using namespace std;

int main()
{
    char input, alphabet = 'A';

    cout << "Enter the uppercase character you want to print in the last row: ";
    cin >> input;

    for(int i = 1; i <= (input-'A'+1); ++i)
    {
        for(int j = 1; j <= i; ++j)
        {
            cout << alphabet << " ";
        }
        ++alphabet;

        cout << endl;
    }
    return 0;
}

Output :

Create_Pyramid.jpg