C# programs to print alphabet pattern


Introduction

In this article, I have explained the list of all alphabet pattern programs in C# programming language. Following exercise is compiled and tested on a Visual Studio 2012.


techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

Alphabet pattern : 1

A
BB
CCC
DDDD
EEEEE

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for(i=1;i<=n;i++)
  11. {
  12. for(j=1;j<=i;j++)
  13. {
  14. Console.Write((char)(i+64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern : 2

AAAAA

BBBB

CCC

DD

E

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = i; j <= n; j++)
  13. {
  14. Console.Write((char)(i+64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern : 3

A
AB
ABC
ABCD
ABCDE

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = 1; j <= i; j++)
  13. {
  14. Console.Write((char)(j+64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern : 4

E

DE

CDE

BCDE

ABCDE

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = n; i >= 1; i--)
  11. {
  12. for (j = i; j <= n; j++)
  13. {
  14. Console.Write((char)(j+64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern : 5

A
BA
CBA
DCBA
EDCBA

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = i; j >= 1; j--)
  13. {
  14. Console.Write((char)(j+64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern : 6

E

ED

EDC

EDCB

EDCBA

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = n; i >= 1; i--)
  11. {
  12. for (j = n; j >= i; j--)
  13. {
  14. Console.Write((char)(j+64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

     


Alphabet pattern 7

E

DD

CCC

BBBB

AAAAA

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = 1; j <= i; j++)
  13. {
  14. Console.Write((char)(n - i + 1 + 64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern 8

EEEEE

DDDD

CCC

BB

A

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = n; i >= 1; i--)
  11. {
  12. for (j = 1; j <= i; j++)
  13. {
  14. Console.Write((char)(i + 64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }


Alphabet pattern 9

EDCBA

EDCB

EDC

ED

E

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = n; j >= i; j--)
  13. {
  14. Console.Write((char)(j + 64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern 10

EDCBA

DCBA

CBA

BA

A

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. int n=5;
  9.  
  10. for (i = n; i >= 1; i--)
  11. {
  12. for (j = i; j >= 1; j--)
  13. {
  14. Console.Write((char)(j + 64));
  15.  
  16. }
  17.  
  18. Console.WriteLine("");
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern 11

A

ABA

ABCBA

ABCDCBA

ABCDEDCBA

  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. int n = 5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12.  
  13. for (j = 1; j <= n - i; j++)
  14. {
  15. Console.Write(" ");
  16. }
  17. for (j = 1; j <= i; j++)
  18. {
  19. Console.Write((char)(j + 64));
  20. }
  21. for (j = i - 1; j >= 1; j--)
  22. {
  23. Console.Write((char)(j + 64));
  24. }
  25.  
  26. Console.WriteLine();
  27. }
  28. Console.ReadLine();
  29. }
  30.  
  31. }

Alphabet pattern 12

 A   
 B C   
 D E F   
 G H I J   
 K L M N O   
 P Q R S T U   
 V W X Y Z
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j, charValue;
  8. charValue = 65;
  9. for (i = 1; i <= 7; i++)
  10. {
  11. Console.WriteLine(" ");
  12. for (j = 1; j <= i; j++)
  13. {
  14. Console.Write(" " + Convert.ToChar(charValue));
  15. charValue++;
  16. if (charValue == 91)
  17. {
  18. break;
  19. }
  20. }
  21. }
  22. Console.ReadLine();
  23. }
  24. }

     


Alphabet pattern 13

ABCDE
 FGHI
  JKL
   MN
    O
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j, k;
  8. char c = 'A';
  9. int n = 5;
  10.  
  11. for (i = 0; i <= n; i++)
  12. {
  13. for (j = 0; j <= i; j++)
  14. {
  15. Console.Write(" ");
  16. }
  17. for (k = n - i - 1; k >= 0; k--)
  18. {
  19. Console.Write(c);
  20. c++;
  21. }
  22. Console.WriteLine();
  23.  
  24. }
  25. Console.ReadLine();
  26. }
  27. }

Alphabet pattern 14

A
BC
DEF
GHIJ
KLMNO
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i,j;
  8. char c;
  9. int n=5;
  10.  
  11. c='A';
  12. for (i = 0; i < n; i++)
  13. {
  14. for (j = 0; j <= i; j++)
  15. {
  16. if (c == 'Z')
  17. break;
  18.  
  19. Console.Write(c);
  20. c++;
  21. }
  22. Console.WriteLine();
  23. }
  24. Console.ReadLine();
  25. }
  26. }

Alphabet pattern 15

ABCDEDCBA
ABCD DCBA
ABC   CBA
AB     BA
A       A
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. char CH = 'E';
  9. int space = 1;
  10.  
  11. for (i = 1; i <= 5; i++)
  12. {
  13. for (j = 'A'; j <= CH; j++)
  14. Console.Write((char)(j));
  15.  
  16. if (i == 1)
  17. Console.Write("\b");
  18.  
  19. for (j = 1; j < space; j++)
  20. Console.Write(" ");
  21.  
  22.  
  23. for (j = CH; j >= 'A'; j--)
  24. Console.Write((char)(j));
  25.  
  26.  
  27. Console.WriteLine();
  28. CH--;
  29. space++;
  30. }
  31. Console.ReadLine();
  32. }
  33. }

Alphabet pattern 16

A 
B C 
D E F 
G H I J 
K L M N O
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. char ch = 'A';
  9. for (i = 1; i <= 5; i++)
  10. {
  11. for (j = 1; j <= i; j++)
  12. {
  13. Console.Write(ch++);
  14. }
  15. Console.WriteLine();
  16.  
  17.  
  18. }
  19. Console.ReadLine();
  20. }
  21.  
  22. }

Alphabet pattern 17

         A
       B A B
     C B A B C
   D C B A B C D
 E D C B A B C D E
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. int n = 5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = 1; j <= n - i; j++)
  13. {
  14. Console.Write(" ");
  15. }
  16. for (j = i; j > 0; j--)
  17. {
  18. Console.Write((char)(j + 64));
  19. }
  20. for (j = 2; j <= i; j++)
  21. {
  22. Console.Write((char)(j + 64));
  23.  
  24. }
  25. Console.WriteLine();
  26. }
  27. Console.ReadLine();
  28. }
  29.  
  30. }

Alphabet pattern 18

A
B F
C G J
D H K M
E I L N O
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. int n = 5;
  9. int diff, value;
  10.  
  11. for (i = 1; i <= n; i++)
  12. {
  13. diff = n - 1;
  14. value = i;
  15. for (j = 1; j <= i; j++)
  16. {
  17. Console.Write((char)(value + 64));
  18. value = value + diff;
  19. diff--;
  20. }
  21. Console.WriteLine();
  22. }
  23. Console.ReadLine();
  24. }
  25.  
  26. }

Alphabet pattern 19

A
A B C
A B C D E
A B C D E F G
A B C D E F G H I
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. int n = 5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = 1; j <= (i * 2 - 1); j++)
  13. {
  14. Console.Write((char)(j + 64));
  15. }
  16. Console.WriteLine();
  17. }
  18. Console.ReadLine();
  19. }
  20.  
  21. }

Alphabet pattern 20

E F G H I
D E F G
C D E
B C
A
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j, k;
  8. int n = 5;
  9.  
  10. for (i = n; i >= 1; i--)
  11. {
  12. k = i;
  13. for (j = 1; j <= i; j++, k++)
  14. {
  15. Console.Write((char)(k + 64));
  16. }
  17. Console.WriteLine();
  18.  
  19. }
  20. Console.ReadLine();
  21. }
  22.  
  23. }

Alphabet pattern 21

A B C D E
B C D E
C D E
D E
E
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. int n = 5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = i; j <= n; j++)
  13. {
  14. Console.Write((char)(j + 64));
  15.  
  16. }
  17. Console.WriteLine();
  18.  
  19. }
  20. Console.ReadLine();
  21. }
  22. }

Alphabet pattern 22

        A
      B B
    C C C
  D D D D
E E E E E
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j, k;
  8. int n = 5;
  9.  
  10. for (i = 1; i <= n; i++)
  11. {
  12. for (j = 1; j <= n - i; j++)
  13. {
  14. Console.Write(" ");
  15. }
  16. for (k = 1; k <= i; k++)
  17. {
  18. Console.Write((char)(i + 64));
  19. }
  20. Console.WriteLine();
  21. }
  22. Console.ReadLine();
  23. }
  24. }

Alphabet pattern 23

 ABCDEF
  GHIJK
   LMNO
    PQR
     ST
      U
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j, k;
  8. char c = 'A';
  9. int n = 6;
  10. for (i = 0; i <= n; i++)
  11. {
  12. for (j = 0; j <= i; j++)
  13. {
  14. Console.Write(" ");
  15. }
  16. for (k = n - i - 1; k >= 0; k--)
  17. {
  18. Console.Write(c);
  19. c++;
  20. }
  21. Console.WriteLine();
  22. }
  23. Console.ReadLine();
  24. }
  25. }

Alphabet pattern 24

A
BC
DEF
GHIJ
KLMNO
PQRSTU
  1. using System;
  2.  
  3. public class AlphabetPattern
  4. {
  5. public static void Main(string[] args)
  6. {
  7. int i, j;
  8. char c;
  9. int n = 6;
  10.  
  11. c = 'A';
  12. for (i = 0; i < n; i++)
  13. {
  14. for (j = 0; j <= i; j++)
  15. {
  16. if (c == 'Z')
  17. break;
  18. Console.Write(c);
  19. c++;
  20. }
  21. Console.WriteLine();
  22.  
  23. }
  24. Console.ReadLine();
  25. }
  26. }





Related Topics



Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.