C# Program to Print Alphabet Triangle - c# - c# tutorial - c# net



How to write Program Print Alphabet Triangle in C# ?

  • There are different triangles that can be printed.
    • Triangles can be generated by alphabets or numbers.
    • learn c# tutorials - triangle numbers - triangel alphabets programs in csharp - c# programs

      Triangle alphabets programs in csharp

    • In this C# program, we are going to print alphabet triangles.

Example to print Alphabet Triangle

Example1:

using System;  
public class PrintExample  
 {  
 public static void Main(string[] args)  
     {  
char ch='A';      
int i, j, k, m;      
for(i=1; i<=5; i++)      
       {      
        for(j=5; j>=i; j--)      
         Console.Write(" ");      
        for(k=1;k<=i;k++)      
         Console.Write(ch++);      
        ch--;      
        for(m=1;m<i;m++)      
         Console.Write(--ch);      
        Console.Write("\n");      
        ch='A';      
       }      
  }  
} 

C# examples - Output :

     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA

Example 2:

#include<stdio.h>
#include<conio.h>

void main()
{
int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%c",'A'-1 + i);
}
printf("\n");
}
getch();
}

C# examples - Output :

A
BB
CCC
DDDD
EEEEE

Example 3:

#include<stdio.h>
#include<conio.h>

void main()
{
int i, j;
for(i=1;i<=5;i++)
{
for(j=5;j>=i;j--)
{
printf("%c",'A'-1 + i);
}
printf("\n");
}
getch();
}

C# examples - Output :

AAAAA
BBBB
CCC
DD
E

Related Searches to C# Program to Print Alphabet Triangle