C++ Program to Print Diamond Alphabets Pattern

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

#include<iostream>
using namespace std;

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

	cout << "Enter Diamond Pattern of Alphabets Rows = ";
	cin >> rows;
		
	cout << "Printing Diamond Alphabets Pattern\n";
	for (i = 1 ; i <= rows; i++ ) 
	{
		for (j = 1 ; j <= rows - i; j++ ) 
		{
			cout << " ";	
		}
		for (k = 1 ; k <= i * 2 - 1; k++ ) 
		{
			cout << char(alphabet + k);
		}
		cout << "\n";
	}
		
	for (i = rows - 1 ; i > 0; i-- ) 
	{
		for (j = 1 ; j <= rows - i; j++ ) 
		{
			cout << " ";
		}
		for (k = 1 ; k <= i * 2 - 1; k++ ) 
		{
			cout << char(alphabet + k);
		}
		cout << "\n";
	}
	return 0;
}
C++ Program to Print Diamond Alphabets Pattern

It is another way of writing the C++ program to print the diamond pattern of alphabets.

#include<iostream>
using namespace std;

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

	cout << "Enter Diamond Pattern of Alphabets Rows = ";
	cin >> rows;
		
	cout << "Printing Diamond Alphabets Pattern\n";

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

	for (i = 0; i <= rows - 1; i++)
	{
		for (j = -1; j <= i; j++)
		{
			cout << " ";
		}
		for (k = 0; k <= rows - i - 2; k++)
		{
			cout << char(alphabet + k) << " ";
		}
		cout << "\n";;
	}
}
Enter Diamond Pattern of Alphabets Rows = 12
Printing Diamond Alphabets Pattern
            A 
           A B 
          A B C 
         A B C D 
        A B C D E 
       A B C D E F 
      A B C D E F G 
     A B C D E F G H 
    A B C D E F G H I 
   A B C D E F G H I J 
  A B C D E F G H I J K 
 A B C D E F G H I J K L 
  A B C D E F G H I J K 
   A B C D E F G H I J 
    A B C D E F G H I 
     A B C D E F G H 
      A B C D E F G 
       A B C D E F 
        A B C D E 
         A B C D 
          A B C 
           A B 
            A 

This C++ example shows the other way to print the Diamond pattern of alphabets.

#include<iostream>
using namespace std;

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

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

	cout << "Printing Diamond Alphabets Pattern\n";

	for (i = 1; i <= rows; i++)
	{
		for (j = 1; j <= rows - i; j++)
		{
			cout << " ";
		}
		for (k = i; k >= 1; k--)
		{
			cout << char(alphabet + k);
		}
		for (l = 2; l <= i; l++)
		{
			cout << char(alphabet + l);
		}
		cout << "\n";
	}

	for (i = rows - 1; i > 0; i--)
	{
		for (j = 1; j <= rows - i; j++)
		{
			cout << " ";
		}
		for (k = i; k >= 1; k--)
		{
			cout << char(alphabet + k);
		}
		for (l = 2; l <= i; l++)
		{
			cout << char(alphabet + l);
		}
		cout << "\n";
	}
}
Enter Diamond Pattern of Alphabets Rows = 14
Printing Diamond Alphabets Pattern
             A
            BAB
           CBABC
          DCBABCD
         EDCBABCDE
        FEDCBABCDEF
       GFEDCBABCDEFG
      HGFEDCBABCDEFGH
     IHGFEDCBABCDEFGHI
    JIHGFEDCBABCDEFGHIJ
   KJIHGFEDCBABCDEFGHIJK
  LKJIHGFEDCBABCDEFGHIJKL
 MLKJIHGFEDCBABCDEFGHIJKLM
NMLKJIHGFEDCBABCDEFGHIJKLMN
 MLKJIHGFEDCBABCDEFGHIJKLM
  LKJIHGFEDCBABCDEFGHIJKL
   KJIHGFEDCBABCDEFGHIJK
    JIHGFEDCBABCDEFGHIJ
     IHGFEDCBABCDEFGHI
      HGFEDCBABCDEFGH
       GFEDCBABCDEFG
        FEDCBABCDEF
         EDCBABCDE
          DCBABCD
           CBABC
            BAB
             A