Hi,
I have successfully created a star pyramid using the below code, but i wanted to know if there is any other method by which i can do it using less loops or variables ??
OR maybe how would you do the star pyramid yourself ?
Code:
SSSS*
SSS***
SS*****
S*******
S= space
Code:
#include <stdio.h>
int main(void)
{
int height,i,j,k=0;
printf("Enter the height of pyramid : ");
scanf("%d",&height);
for(i=1;i<=height;i++)
{
for(j=1;j<=height-i;j++)
{
printf(" ");
}
for(j=1;j<=i+k;j++)
{
printf("*");
}
printf("\n");
k+=1;
}
getch();
}