C++ Program to Print Triangle of Alphabets in Reverse Pattern

Write a C++ program to print triangle of alphabets in reverse pattern using for loop.

#include<iostream>
using namespace std;

int main()
{
	int rows;

	cout << "Enter Triangle of Alphabets in Reverse Rows = ";
	cin >> rows;

	cout << "printing Triangle of Alphabets in Reverse Order\n";

	int alphabet = 65;

	for (int i = rows - 1; i >= 0; i--)
	{
		for (int j = 0; j < i; j++)
		{
			cout << " ";
		}
		for (int k = i; k <= rows - 1; k++)
		{
			cout << char(alphabet + k) << " ";
		}
		cout << "\n";
	}
}
C++ Program to Print Triangle of Alphabets in Reverse Pattern

C++ program to print the triangle of alphabets in reverse pattern using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int rows, i, j, k, alphabet;
	
	cout << "Enter Triangle of Alphabets in Reverse Rows = ";
	cin >> rows;

	cout << "printing Triangle of Alphabets in Reverse Order\n";

	alphabet = 65;

	i = rows - 1;
	while (i >= 0)
	{

		j = 0;
		while (j < i)
		{
			cout << " ";
			j++;
		}

		k = i;
		while (k <= rows - 1)
		{
			cout << char(alphabet + k) << " ";
			k++;
		}
		cout << "\n";
		i--;
	}
}
Enter Triangle of Alphabets in Reverse Rows = 11
printing Triangle of Alphabets in Reverse Order
          K 
         J K 
        I J K 
       H I J K 
      G H I J K 
     F G H I J K 
    E F G H I J K 
   D E F G H I J K 
  C D E F G H I J K 
 B C D E F G H I J K 
A B C D E F G H I J K 

This C++ pattern example prints the triangle of alphabets in descending order or reverse order using the do while loop.

#include<iostream>
using namespace std;

int main()
{
	int rows, i, j, k, alphabet;
	
	cout << "Enter Triangle of Alphabets in Reverse Rows = ";
	cin >> rows;

	cout << "printing Triangle of Alphabets in Reverse Order\n";

	alphabet = 65;

	i = rows - 1;
	do
	{

		j = 0;
		do
		{
			cout << " ";

		} while (j++ < i);

		k = i;
		do
		{
			cout << char(alphabet + k) << " ";

		} while (++k <= rows - 1);

		cout << "\n";

	} while (--i >= 0);
}
Enter Triangle of Alphabets in Reverse Rows = 14
printing Triangle of Alphabets in Reverse Order
              N 
             M N 
            L M N 
           K L M N 
          J K L M N 
         I J K L M N 
        H I J K L M N 
       G H I J K L M N 
      F G H I J K L M N 
     E F G H I J K L M N 
    D E F G H I J K L M N 
   C D E F G H I J K L M N 
  B C D E F G H I J K L M N 
 A B C D E F G H I J K L M N 

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.