C++ Program:

- To print full triangle pattern using alphabet

Example:

User Input: 3

Output:

    A
  A B A
A B C B A
#include <iostream>
using namespace std;

int main() {
  int rows;
  char c;
  cout <<"Enter number of rows: ";
  cin >> rows;
  for(int i=rows; i>=1; i--) {
    c='A';
    for(int j=1; j<=(2*rows-i); j++) {
      if(j<i)cout<<"  ";
      else {
        if(j<rows)cout<<c++<<" ";
        else cout<<c--<<" ";
      }
    }
    cout<<endl;
  }
  return 0;
}

Output:

Enter number of rows: 4

      A
    A B A
  A B C B A
A B C D C B A
Program
pattern

Main Logic :

for(int i=rows; i>=1; i--) {
  c='A';
  for(int j=1; j<=(2*rows-i); j++) {
    if(j<i)cout<<"  ";
    else {
      if(j<rows)cout<<c++<<" ";
      else cout<<c--<<" ";
    }
  }
  cout<<endl;
}

You can print the same pattern in small alphabets, just set c='a'

Concept

Coming Soon !

Quick
Tutorial

Quote

We are all now connected by the Internet, like neurons in a giant brain.