Write a C program to print a Pyramid
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
int n,i,j,sp;
printf("Enter Number of Rows");
scanf("%d",&n);
for(i=1;
n>=i; i++)
{
for(sp=n-i;
sp>=1; sp--)
printf(" ");
for(j=i;
j>=1; j--)
printf("*");
for(j=i;
j>1; j--)
printf("*");
printf("\n");
}
getch();
return 0;
}
Output:
No comments:
Post a Comment