Cpp program to print triangle alphabet pattern
- Home
- Alphabet Pattern
- Cpp program to print triangle alphabet pattern
- On
- By
- 0 Comment
- Categories: Alphabet Pattern, Floyd's triangle
Cpp program to print triangle alphabet pattern
Cpp program to print triangle alphabet pattern
In this tutorial, we will discuss a concept of Cpp program to print triangle alphabet pattern using for loop in C++ language.
here, we displayed 15 alphabet Floyd’s triangle program with coding and using nested for loop and also we get input from user using cin function.
the user can provide numbers as they wish and get the alphabet pattern according to their input
Java program to display triangle alphabet pattern
Floyd’s Triangle Alphabet Pattern 1
Program 1
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; cin>>rows; cout << "\nHere your pattern\n\n"; for(i=1; i<=rows; i++){ for(j=1; j<=i; j++){ cout<<((char)(i+64)); } cout<< endl; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter number of rows: 6 Here your pattern A BB CCC DDDD EEEEE FFFFFF
Floyd’s Triangle Alphabet Pattern 2
Program 2
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; cin>>rows; cout << "\nHere your pattern\n\n"; for(i=1; i<=rows; i++){ for(j=1; j<=i; j++){ cout<<((char)(j+64)); } cout<< endl; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter number of row: 6 Here your pattern A AB ABC ABCD ABCDE ABCDEF
Floyd’s Triangle Alphabet Pattern 3
Program 3
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; cin>>rows; cout << "\nHere your pattern\n\n"; for(i=1; i<=rows; i++){ for(j=i; j<=rows; j++){ cout<<((char)(i+64)); } cout<< endl; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter your number of rows: 6 Here your pattern AAAAAA BBBBB CCCC DDD EE F
Floyd’s Triangle Alphabet Pattern 4
Program 4
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows:" << endl; cin>>rows; cout<<"\n"; cout<<"Here, your pattern\n"; for(i=1; i<=rows; i++){ for(j=i; j>=1; j--){ cout<<((char)(j-1+65)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows: 6 Here, your pattern A BA CBA DCBA EDCBA FEDCBA
Floyd’s Triangle Alphabet Pattern 5
Program 5
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows:" << endl; cin>>rows; cout<<"\n"; cout<<"Here, your pattern\n"; for(i=rows; i>=1; i--){ for(j=i; j<=rows; j++){ cout<<((char)(j+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows: 6 Here, your pattern F EF DEF CDEF BCDEF ABCDEF
Floyd’s Triangle Alphabet Pattern 6
Program 6
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows:" << endl; cin>>rows; cout<<"\n"; cout<<"Here, your pattern\n"; for(i=rows; i>=1; i--){ for(j=rows; j>=i; j--){ cout<<((char)(j+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows: 6 Here, your pattern F FE FED FEDC FEDCB FEDCBA
Floyd’s Triangle Alphabet Pattern 7
Program 7
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows:" << endl; cin>>rows; cout<<"\n"; cout<<"Here, your pattern\n"; for(i=rows; i>=1; i--){ for(j=1; j<=i; j++){ cout<<((char)(j+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows: 6 Here, your pattern ABCDEF ABCDE ABCD ABC AB A
Floyd’s Triangle Alphabet Pattern 8
Program 8
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=1; i<=rows; i++){ for(j=1; j<=i; j++){ cout<<((char)(rows-i+1+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern F EE DDD CCCC BBBBB AAAAAA
Floyd’s Triangle Alphabet Pattern 9
Program 9
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=rows; i>=1; i--){ for(j=1; j<=i; j++){ cout<<((char)(i+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern FFFFFF EEEEE DDDD CCC BB A
Floyd’s Triangle Alphabet Pattern 10
Program 10
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=1; i<=rows; i++){ for(j=rows; j>=i; j--){ cout<<((char)(j+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern FEDCBA EDCBA DCBA CBA BA A
Floyd’s Triangle Alphabet Pattern 11
Program 11
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=rows; i>=1; i--){ for(j=i; j>=1; j--){ cout<<((char)(j+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern FEDCBA EDCBA DCBA CBA BA A
Floyd’s Triangle Alphabet Pattern 12
Program 12
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; char alphabet='A'; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=1; i<=rows; i++){ for(j=1; j<=i; j++){ cout<<alphabet++; } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern A BC DEF GHIJ KLMNO PQRSTU
Floyd’s Triangle Alphabet Pattern 13
Program 13
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows,num,count1; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=1; i<=rows; i++){ num=rows-1; count1=i; for(j=1; j<=i; j++){ cout<<((char)(count1+64)); count1=count1+num; num--; } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern A BG CHL DIMP EJNQS FKORTU
Floyd’s Triangle Alphabet Pattern 14
Program 14
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,k,rows; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=rows; i>=1; i--){ k=i; for(j=1; j<=i; j++,k++){ cout<<((char)(k+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern FGHIJK EFGHI DEFG CDE BC A
Floyd’s Triangle Alphabet Pattern 15
Program 15
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,k,rows; cout << "Enter the number of rows" << endl; cin>>rows; cout << "\nHere your pattern\n" << endl; for(i=1; i<=rows; i++){ for(j=i; j<=rows; j++){ cout<<((char)(j+64)); } cout<<"\n"; } getch(); return 0; }
When the above code is executed, it produces the following results
Enter the number of rows 6 Here your pattern ABCDEF BCDEF CDEF DEF EF F
Suggested for you
Nested for loop in C++