In this C program, we will learn how to write a program to print the half inverted pyramid using digits and alphabets.
Here is the code of the program to print the half inverted pyramid using digits and alphabets.
/*
C Program to Print Half Inverted Pyramid using digits and Alphabets
1A2B3C4D5E
1A2B3C4D
1A2B3C
1A2B
1A
*/
#include <stdio.h>
int main()
{
int i,j,k,number;
printf("Enter The Number of Rows: ");
scanf("%d",&number);
/*Run parent loop*/
for(i=number; i>=1; i--)
{
for(j=1, k='A'; j<=i; j++,k++)
{
printf("%d%c",j,k);
}
printf("\n");
}
return 0;
}
Enter The Number of Rows: 5
1A2B3C4D5E
1A2B3C4D
1A2B3C
1A2B
1A
--------------------------------
Process exited after 1.714 seconds with return value 0
Press any key to continue . . .
Comments