Aim :- Write a C Program to Print Full Pyramid Using Numbers.
C program to For Generating Full Pyramid Using Numbers.
The Number of Rows Will Be Given By User.
C++ Program Code :
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n, k=0, p = 0, pa = 0;
clrscr();
printf("\nC Program To Print Full Pyramid Using Numbers.");
printf("\n\nEnter Number of Rows : ");
scanf("%d",&n);
for(i=1; i<=n; ++i)
{
for(j=1; j <= n-i; ++j)
{
printf(" ");
++p;
}
while(k != 2*i-1)
{
if (p <= n-1)
{
printf("%d ", i+k);
++p;
}
else
{
++pa;
printf("%d ", (i+k-2*pa));
}
++k;
}
pa = p = k = 0;
printf("\n");
}
getch();
}
Output :
0 Comments