In this article, we will show how to write a C program to print the right angled triangle of the same alphabet in each row and column using for loop, while loop, and functions.
The below example allows the user to enter the total number of rows, and the nested for loop iterates them from start to end. Next, the program will print the right angled triangle of the same alphabet, i.e., A.
#include <stdio.h>
int main()
{
int rows, a = 65;
printf("Enter Rows = ");
scanf("%d",&rows);
for (int i = 0 ; i < rows; i++ )
{
for (int j = 0 ; j <= i; j++ )
{
printf("%c ", a);
}
printf("\n");
}
return 0;
}
Enter Rows = 15
A
A A
A A A
A A A A
A A A A A
A A A A A A
A A A A A A A
A A A A A A A A
A A A A A A A A A
A A A A A A A A A A
A A A A A A A A A A A
A A A A A A A A A A A A
A A A A A A A A A A A A A
A A A A A A A A A A A A A A
A A A A A A A A A A A A A A A
Instead of a C language for loop, this program uses a C code while loop to iterate the right angled triangle rows and columns and prints the same alphabet A at each position.
#include <stdio.h>
int main()
{
int i, j, rows, a = 65;
printf("Enter Rows = ");
scanf("%d",&rows);
i = 0 ;
while (i < rows)
{
j = 0;
while (j <= i)
{
printf("%c ", a);
j++;
}
printf("\n");
i++;
}
return 0;
}
Enter Rows = 11
A
A A
A A A
A A A A
A A A A A
A A A A A A
A A A A A A A
A A A A A A A A
A A A A A A A A A
A A A A A A A A A A
A A A A A A A A A A A
It allows the user to choose the alphabet character along with the number of rows. Next, within this C program, we create a RightTriangleSameAlphabet function in C that accepts those values and prints the right angled triangle of the given alphabet in all rows and columns.
For more topics of the alphabets, please refer to the C Alphabet Pattern Programs post.
#include <stdio.h>
void RightTriangleSameAlphabet(int rows, char a)
{
for (int i = 0 ; i < rows; i++ )
{
for (int j = 0 ; j <= i; j++ )
{
printf("%c ", a);
}
printf("\n");
}
}
int main()
{
int rows;
char a;
printf("Enter Alphabet = ");
scanf("%c", &a);
printf("Enter Rows = ");
scanf("%d",&rows);
RightTriangleSameAlphabet(rows, a);
return 0;
}

Also Read
- C Program to Print Right Triangle of Same Alphabet in each Column
- C Program to Print Right Triangle of Mirrored Alphabets Pattern