Write a C++ program to print square of right increment alphabets pattern using for loop.
#include<iostream> using namespace std; int main() { int rows; cout << "Enter Square of Incremented Alphabets Rows = "; cin >> rows; cout << "Square of Right Incremented Alphabets Pattern\n"; int alphabet = 65; for (int i = 0; i <= rows - 1; i++) { for (int j = rows - 1; j > i; j--) { cout << "A "; } for (int k = 0; k <= i; k++) { cout << char(alphabet + i) << " "; } cout << "\n"; } }
This C++ program prints the square pattern of increment alphabets from the right hand side using a while loop.
#include<iostream> using namespace std; int main() { int rows, i, j, k, alphabet; cout << "Enter Square of Incremented Alphabets Rows = "; cin >> rows; cout << "Square of Right Incremented Alphabets Pattern\n"; alphabet = 65; i = 0; while (i <= rows - 1) { j = rows - 1; while (j > i) { cout << "A "; j--; } k = 0; while (k <= i) { cout << char(alphabet + i) << " "; k++; } cout << "\n"; i++; } }
Enter Square of Incremented Alphabets Rows = 13
Square of Right Incremented Alphabets Pattern
A A A A A A A A A A A A A
A A A A A A A A A A A B B
A A A A A A A A A A C C C
A A A A A A A A A D D D D
A A A A A A A A E E E E E
A A A A A A A F F F F F F
A A A A A A G G G G G G G
A A A A A H H H H H H H H
A A A A I I I I I I I I I
A A A J J J J J J J J J J
A A K K K K K K K K K K K
A L L L L L L L L L L L L
M M M M M M M M M M M M M