Full pyramid program and size is given by user
Code :
#include<stdio.h>
#include<conio.h>
/*============================
Girfa Student Help
Full pyramid program
==============================*/
void main()
{
int i,j,sp,size,k;
clrscr();
printf("Enter
Pyramid size>> ");
scanf("%d",&size);
if(size>12)
puts("pyramid
size out of screen resolution");
else
{
sp=size;
/* Upper
pyramid */
for(i=1,k=1;i<size;i++)
{
for(j=1;j<=sp;j++)
printf(" ");
for(j=1;j<=k;j++)
printf("*");
printf("\n");
k=k+2;
sp--;
}
/* Lower
pyramid */
for(i=1;i<=size;i++)
{
for(j=1;j<=sp;j++)
printf(" ");
for(j=1;j<=k;j++)
printf("*");
printf("\n");
k=k-2;
sp++;
}
}
getch();
}
No comments:
Post a Comment