Header Ads Widget

Ticker

6/recent/ticker-posts

C++ Program to Print Alphabet Triangle Note+Coding by Digitalise Data

 

C++ Program to Print Alphabet Triangle Note+Coding by Digitalise Data

C++ Program to Print Alphabet Triangle

There are different triangles that can be printed. Triangles can be generated by alphabets or numbers. In this C++ program, we are going to print alphabet triangles.

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

  1. #include iostreamm.h>
  2. #include <conio.h>
  3. void main() 
  4. {  
  5.  char ch='A';    
  6.     int i, j, k, m;    
  7.     for(i=1;i<=5;i++)    
  8.     {    
  9.         for(j=5;j>=i;j--)    
  10.             cout<<" ";    
  11.         for(k=1;k<=i;k++)    
  12.             cout<<ch++;    
  13.             ch--;    
  14.         for(m=1;m<i;m++)    
  15.             cout<<--ch;    
  16.         cout<<"\n";    
  17.         ch='A';    
  18.     }    
  19. getch (); 
  20. }  

Output:

     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA

Post a Comment

0 Comments