In this article, we are going to learn about how to print a Full Pyramid pattern in C language.
Print Full Pyramid pattern of Numbers in C language
Desired Output for Size 5:
1
121
12321
1234321
123454321
C Program to print full pyramid pattern of numbers
#include<stdio.h>
int main()
{
int num, a,n;
printf("Please enter the number of rows: ");
scanf("%d",&n);
for(int r=1; r<=n; r++)
{
for(int c=1; c<=n-r; c++)
printf(" ");
for(int k=1;k<=(2*r-1);k++)
{
if(k<r)
printf("%d",k);
else if(k==r)
{
printf("%d",k);
a=k;
}
else
printf("%d",--a);
}
printf("\n");
}
return 0;
}
Output
Please enter the number of rows: 5
1
121
12321
1234321
123454321