C++ Program to Print Right Arrow Alphabets Pattern

Write a C++ program to print right arrow alphabets pattern using for loop.

#include<iostream>
using namespace std;

int main()
{
	int rows, i, j, k, alphabet;

	cout << "Enter Right Arrow Pattern of Alphabets Rows = ";
	cin >> rows;

	cout << "The Right Arrow Alphabets Pattern\n";
	alphabet = 65;

	for (i = 0; i < rows; i++)
	{
		for (j = 0; j < i; j++)
		{
			cout << " ";
		}
		for (k = i; k < rows; k++)
		{
			cout << char(alphabet + k);
		}
		cout << "\n";
	}

	for (i = rows - 2; i >= 0; i--)
	{
		for (j = 0; j < i; j++)
		{
			cout << " ";
		}
		for (k = i; k <= rows - 1; k++)
		{
			cout << char(alphabet + k);
		}
		cout << "\n";
	}
}
C++ Program to Print Right Arrow Alphabets Pattern

This C++ example prints the right arrow pattern of alphabets using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int rows, i, j, k, alphabet;

	cout << "Enter Right Arrow Pattern of Alphabets Rows = ";
	cin >> rows;

	cout << "The Right Arrow Alphabets Pattern\n";
	alphabet = 65;
	i = 0;

	while (i < rows)
	{
		j = 0;
		while (j < i)
		{
			cout << " ";
			j++;
		}
		k = i;
		while (k < rows)
		{
			cout << char(alphabet + k);
			k++;
		}
		cout << "\n";
		i++;
	}

	i = rows - 2;
	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 Right Arrow Pattern of Alphabets Rows = 12
The Right Arrow Alphabets Pattern
ABCDEFGHIJKL
 BCDEFGHIJKL
  CDEFGHIJKL
   DEFGHIJKL
    EFGHIJKL
     FGHIJKL
      GHIJKL
       HIJKL
        IJKL
         JKL
          KL
           L
          KL
         JKL
        IJKL
       HIJKL
      GHIJKL
     FGHIJKL
    EFGHIJKL
   DEFGHIJKL
  CDEFGHIJKL
 BCDEFGHIJKL
ABCDEFGHIJKL