c++ pyramid but i need to input letter for same result? [closed]

  c++, input

in code is input for number.
but I need to enter the input "letter" to have same result.
pls help mee.

to input letter and to have this result"

               a
               aba
             abcba

language: c++

#include <iostream>
using namespace std;

int main()
{
    int i, j;
    char alph = 'A';
    int n, blk;
    int ctr = 1;
    cout << "nn Display the pattern like pyramid using the alphabet:n";
    cout << "---------------------------------------------------------n";
    cout << " Input the number of Letters (less than 26) in the Pyramid: ";
    cin >> n;
    for (i = 1; i <= n; i++) {
        for (blk = 1; blk <= n - i; blk++)
            cout << "  ";
        for (j = 0; j <= (ctr / 2); j++) 
        {
            cout << alph++ << " ";
        }
        alph = alph - 2;
        for (j = 0; j < (ctr / 2); j++) 
        {
            cout << alph-- << " ";
        }
        ctr = ctr + 2;
        alph = 'A';
        cout << endl;
    }
}

enter image description here

in code is input for number.
but I need to enter the input "letter" to have same result.
pls help mee.

Source: Windows Questions C++

LEAVE A COMMENT