#include <stdio.h>
#include <conio.h>
int main()
{
int row, c, p, temp;
printf("Enter the number of rows in pyramid ");
scanf("%d",&p);
temp = p;
for ( row = 1 ; row <= p ; row++ )
{
for ( c = 1 ; c < temp ; c++ )
printf(" ");
temp--;
for ( c = 1 ; c <= 2*row - 1 ; c++ )
printf("*");
printf("\n");
}
return 0;
}
output
#include <conio.h>
int main()
{
int row, c, p, temp;
printf("Enter the number of rows in pyramid ");
scanf("%d",&p);
temp = p;
for ( row = 1 ; row <= p ; row++ )
{
for ( c = 1 ; c < temp ; c++ )
printf(" ");
temp--;
for ( c = 1 ; c <= 2*row - 1 ; c++ )
printf("*");
printf("\n");
}
return 0;
}
output
No comments:
Post a Comment