Write a C++ program to print left arrow alphabets pattern using for loop.
#include<iostream> using namespace std; int main() { int rows, i, j, alphabet; cout << "Enter Left Arrow Pattern of Alphabets Rows = "; cin >> rows; cout << "The Left Arrow Alphabets Pattern\n"; alphabet = 65; for (i = rows - 1; i >= 0; i--) { for (j = i; j >= 0; j--) { cout << char(alphabet + j) << " "; } cout << "\n"; } for (i = 0; i < rows; i++) { for (j = i; j >= 0; j--) { cout << char(alphabet + j) << " "; } cout << "\n"; } }
C++ program to print left arrow alphabets pattern using a while loop.
#include<iostream> using namespace std; int main() { int rows, i, j, alphabet; cout << "Enter Left Arrow Pattern of Alphabets Rows = "; cin >> rows; cout << "The Left Arrow Alphabets Pattern\n"; alphabet = 65; i = rows - 1; while (i >= 0) { j = i; while (j >= 0) { cout << char(alphabet + j) << " "; j--; } cout << "\n"; i--; } i = 0; while (i < rows) { j = i; while (j >= 0) { cout << char(alphabet + j) << " "; j--; } cout << "\n"; i++; } }
Enter Left Arrow Pattern of Alphabets Rows = 13
The Left Arrow Alphabets Pattern
M L K J I H G F E D C B A
L K J I H G F E D C B A
K J I H G F E D C B A
J I H G F E D C B A
I H G F E D C B A
H G F E D C B A
G F E D C B A
F E D C B A
E D C B A
D C B A
C B A
B A
A
A
B A
C B A
D C B A
E D C B A
F E D C B A
G F E D C B A
H G F E D C B A
I H G F E D C B A
J I H G F E D C B A
K J I H G F E D C B A
L K J I H G F E D C B A
M L K J I H G F E D C B A
This C++ example displays the left arrow pattern of alphabets using a do while loop.
#include<iostream> using namespace std; int main() { int rows, i, j, alphabet; cout << "Enter Left Arrow Pattern of Alphabets Rows = "; cin >> rows; cout << "The Left Arrow Alphabets Pattern\n"; alphabet = 65; i = rows - 1; do { j = i; do { cout << char(alphabet + j) << " "; } while (--j >= 0); cout << "\n"; } while (--i >= 0); i = 0; do { j = i; do { cout << char(alphabet + j) << " "; } while (--j >= 0); cout << "\n"; } while (++i < rows); }
Enter Left Arrow Pattern of Alphabets Rows = 17
The Left Arrow Alphabets Pattern
Q P O N M L K J I H G F E D C B A
P O N M L K J I H G F E D C B A
O N M L K J I H G F E D C B A
N M L K J I H G F E D C B A
M L K J I H G F E D C B A
L K J I H G F E D C B A
K J I H G F E D C B A
J I H G F E D C B A
I H G F E D C B A
H G F E D C B A
G F E D C B A
F E D C B A
E D C B A
D C B A
C B A
B A
A
A
B A
C B A
D C B A
E D C B A
F E D C B A
G F E D C B A
H G F E D C B A
I H G F E D C B A
J I H G F E D C B A
K J I H G F E D C B A
L K J I H G F E D C B A
M L K J I H G F E D C B A
N M L K J I H G F E D C B A
O N M L K J I H G F E D C B A
P O N M L K J I H G F E D C B A
Q P O N M L K J I H G F E D C B A