This is a nested for loop program in which we are going to see how to print the above pattern of Triangle of Alphabets, with the help of the C Programming language.
#include <stdio.h>
int main()
{
int number = 'A', i, j, n;
printf("Enter number of rows");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
// (char)-this keyword convert the ASCII value to the Alphabets.
printf("%c", (char)number);
number = (char)number + 1;
}
printf("\n");
}
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP