C++ Program:

- To print half triangle pattern using alphabet

Example:

User Input: 3

Output:

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

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

Output:

  Enter number of rows : 4
  A
  B B
  C C C
  D D D D
Program
pattern

Main logic :

c='A';
for(int i=1; i<=rows; i++) {  //rows : number of rows to print
  for(int j=1; j<=i; j++) {
    cout<<c<<" ";
  }
  c++;
  cout<<endl;
}

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

Concept

Coming Soon !

Quick
Tutorial

Quote

Sometimes it’s the smallest decisions that can change your life forever.