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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…