In this C program, we will learn how to write a program to print the full pyramid using alphabets in palindromic format.
Here is the code of the program to print the full pyramid using alphabets in palindromic format.
/*
C program to print Full pyramid using Alphabets
A
BAB
CBABC
DCBABCD
EDCBABCDE
*/
#include <stdio.h>
int main()
{
int i,j,number;
char CH='A';
int space;
printf("Enter The Number of Rows: ");
scanf("%d",&number);
space = number;
/*loop for row*/
for(i=1; i<=number; i++)
{
/*put space*/
for(j=1; j<=space; j++)
printf(" ");
/*first part of the row*/
for(j=CH; j>='A'; j--)
printf("%c",j);
/*second part of the row*/
for(j='B'; j<=CH; j++)
printf("%c",j);
printf("\n");
CH++;
space--;
}
return 0;
}
Enter The Number of Rows: 5
A
BAB
CBABC
DCBABCD
EDCBABCDE
--------------------------------
Process exited after 3.347 seconds with return value 0
Press any key to continue . . .
Comments