C Program to Print Triangle Alphabets Pattern

Write a C program to print triangle alphabets pattern using for loop.

#include <stdio.h>

int main()
{
    int i, j, k, rows, alphabet;
    
    printf("Enter Triangle Alphabets Pattern Rows = ");
    scanf("%d",&rows);

    printf("\nThe Triangle Alphabets Pattern\n"); 
    
	for (i = 0 ; i < rows; i++ ) 
	{
		alphabet = 65;
		for (j = rows ; j > i; j-- ) 	
		{
			printf(" ");
		}
		for(k = 0; k <= i; k++)
		{
			printf("%c ", alphabet + k);
		}
		printf("\n");
	}

    return 0;
}
C Program to Print Triangle Alphabets Pattern

This C example displays the alphabets in a triangle pattern using a while loop.

#include <stdio.h>

int main()
{
    int i = 0, j, k, rows, alphabet;
    
    printf("Enter Rows = ");
    scanf("%d",&rows);

    
	while (i < rows) 
	{
		alphabet = 65;
		j = rows ;
		while ( j > i ) 	
		{
			printf(" ");
			j--;
		}
		k = 0;
		while( k <= i)
		{
			printf("%c ", alphabet + k);
			k++;
		}
		printf("\n");
		i++;
	}

    return 0;
}
Enter Rows = 12


            A 
           A B 
          A B C 
         A B C D 
        A B C D E 
       A B C D E F 
      A B C D E F G 
     A B C D E F G H 
    A B C D E F G H I 
   A B C D E F G H I J 
  A B C D E F G H I J K 
 A B C D E F G H I J K L 

C program to print the triangle pattern of alphabets or characters using a do while loop.

#include <stdio.h>

int main()
{
    int i = 0, j, k, rows, alphabet;
    
    printf("Enter Rows = ");
    scanf("%d",&rows);

    
	do 
	{
		alphabet = 65;
		j = rows ;
		do 	
		{
			printf(" ");

		} while ( --j > i );
		k = 0;
		do
		{
			printf("%c ", alphabet + k);

		} while( ++k <= i);
		printf("\n");

	} while (++i < rows);

    return 0;
}
Enter Rows = 15


               A 
              A B 
             A B C 
            A B C D 
           A B C D E 
          A B C D E F 
         A B C D E F G 
        A B C D E F G H 
       A B C D E F G H I 
      A B C D E F G H I J 
     A B C D E F G H I J K 
    A B C D E F G H I J K L 
   A B C D E F G H I J K L M 
  A B C D E F G H I J K L M N 
 A B C D E F G H I J K L M N O 

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.