C++ Program to Alphabet triangle pattern using do-while loop
- Home
- Alphabet Pattern
- C++ Program to Alphabet triangle pattern using do-while loop
- On
- By
- 0 Comment
- Categories: Alphabet Pattern, Floyd's triangle
C++ Program to Alphabet triangle pattern using do-while loop
C++ program to Alphabet triangle pattern using the do-while loop
In this article, we will discuss the concept of C++ program to Alphabet triangle pattern using the do-while loop
We can print various type of number, asterisk, binary patterns using for, while and do-while loop in C++ programming language
In this post, we will discuss how to write a program to print different alphabet triangle pattern using the do-while loop in C++ language.
To understand this example programs, you should have previous knowledge of following C++ topics
Nested do while loop in C++ language
Code to Alphabet triangle pattern 1
Program 1
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows:" << endl; //get input from the user for number of rows cin>>rows; cout<<"\n"; cout<<"Here, your pattern\n"; i=rows; do{ j=1; do{ cout<<((char)(j+64)); j++; } while( j<=i); cout<<"\n"; i--; }while( i>=1); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 2
Program 2
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows" << endl; //get input from the user for number of rows cin>>rows; cout<<"\n"; i=1; do{ j=1; do{ cout<<(char)(j+64); j++; }while(j<=i); i++; cout<<"\n"; }while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 3
Program 3
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter the number of rows" << endl; //get input from the user for number of rows cin>>rows; cout<<"\n"; i=rows; do{ j=i; do{ cout<<((char)(j+64)); j--; }while(j>=1); i--; cout<<"\n"; }while(i>=1); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 4
Program 4
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,k,rows; cout << "Enter the number of rows" << endl; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n" << endl; i=1; do{ j=i; do{ cout<<((char)(j+64)); j++; }while(j<=rows); cout<<"\n"; i++; }while( i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 5
Program 5
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=1; do{ j=i; do{ cout<<((char)(i+64)); j++; }while(j<=rows); cout<< endl; i++; } while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 6
Program 6
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; char ch='A'; cout<<"Enter the number of rows: "; //get input from the user for number of rows cin>>rows; i=1; do{ j=1; do{ cout<<ch++<<" "; j++; } while(j<=i); i++; cout<<"\n"; } while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 7
Program 7
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; char ch='A'; cout<<"Enter the number of rows: "; //get input from the user for number of rows cin>>rows; i=1; do{ j=1; do{ cout<<((char)(j+64))<<" "; j++; }while(j<=(i*2-1)); i++; cout<<"\n"; } while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 8
Program 8
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=1; do{ j=1; do{ cout<<(char)(i+64); j++; } while(j<=i); cout<< endl; i++; } while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 9
Program 9
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows,num,count1; cout<<"Enter the number of rows: "; //get input from the user for number of rows cin>>rows; i=1; do{ num=rows-1; count1=i; j=1; do{ cout<<(char)(count1+64)<<" "; count1=count1+num; num--; j++; }while(j<=i); i++; cout<<"\n"; }while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 10
Program 10
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=rows; do{ j=i; do{ cout<<(char)(j+64); j++; } while(j<=rows); cout<< endl; i--; }while(i>=1); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 11
Program 11
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=1; do{ j=i; do{ cout<<(char)(j+64); j--; }while(j>=1); cout<< endl; i++; }while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 12
Program 12
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=1; do{ j=1; do{ cout<<(char)(rows-i+1+64); j++; }while(j<=i); cout<< endl; i++; }while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 13
Program 13
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=rows; do{ j=rows; do{ cout<<(char)(j+64); j--; }while(j>=i); cout<< endl; i--; } while(i>=1); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 14
Program 14
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=rows; do{ j=1; do{ cout<<(char)(i+64); j++; }while(j<=i); cout<< endl; i--; }while(i>=1); getch(); return 0; }
When the above code is executed, it produces the following results
Code to Alphabet triangle pattern 15
Program 15
#include <iostream> #include <conio.h> using namespace std; int main() { int i,j,rows; cout << "Enter number of rows: "; //get input from the user for number of rows cin>>rows; cout << "\nHere your pattern\n\n"; i=1; do{ j=rows; do{ cout<<(char)(j+64); j--; }while(j>=i); cout<< endl; i++; } while(i<=rows); getch(); return 0; }
When the above code is executed, it produces the following results
Suggested for you
Similar post
C code to Alphabet triangle pattern using the do-while loop
C++ code to Alphabet triangle pattern using the do-while loop
Java code to Alphabet triangle pattern using the do-while loop
Alphabet triangle pattern in C language
Alphabet triangle pattern in C language using while loop
Alphabet triangle pattern in Java language
Alphabet triangle pattern in Java language using while loop
Alphabet triangle pattern in C++ language
Alphabet triangle pattern in C++ language using while loop