Home » Programming » C++ » C++ Program to Print Alphabet Triangle

C++ Program to Print Alphabet Triangle

This article shows that C++ Program to Print Alphabet Triangle. There are different-different type of triangles that can be printed. Triangles can be generated by alphabets or numbers or lines or special characters. In this C++ program, we are going to print alphabet triangles.

C++ Program to print Number Triangle.

Let’s see the C++ example to print alphabet triangle.

#include <iostream>  
using namespace std;  
int main()  
{  
 char ch='A';    
    int i, j, k, m;    
    for(i=1;i<=5;i++)    
    {    
        for(j=5;j>=i;j--)    
            cout<<" ";    
        for(k=1;k<=i;k++)    
            cout<<ch++;    
            ch--;    
        for(m=1;m<i;m++)    
            cout<<--ch;    
        cout<<"\n";    
        ch='A';    
    }    
return 0;  
}  

Output:

          A 
       ABA 
    ABCBA 
  ABCDCBA 
ABCDEDCBA
Note: If you interested lo learn C++ through web, You can click here

Conclusion:

Hi guys, I can hope that you can know that how to write a C++ Program to Print Alphabet Triangle. If you like this post as well as know something new so share this article in your social media accounts. If you have any doubt related to this post then you ask in comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *