#include
#include
void space(int i)
{
while(i>=0)
{
printf(" ");
i--;
}
}
void pyramid (int n,int num)
{
int i,x=1;
while(n>0)
{
space(n);
for(i=0;i
printf(" %d",num);
x++;
printf("\n");
n--;
}
}
void main()
{
int rows, num;
clrscr();
printf("\nEnter the a digit : ");
scanf("%d",&num);
printf("\nEnter the number of rows (less than 35) : ");
scanf("%d",&rows);
printf("\n\n");
pyramid(rows,num);
getch();
}
Algorithm
space(i)
step 1: start
step 2: check whether i>=0,then go to step 3
else go to step 5
step 3: print " "
step 4: i=i-1
step 5: stop
pyramid(n,num)
step 1: start
step 2: intilize x<-1 br="">step 3: check whether n>0 then go to step 4
else go to step13
step 4 : Call space(n)
step 5: intilize i<-0 br="">step 6: check whether i else go to step 8
step 7: print num
step 8: i=i+1
step 9: go to step 8
step 10: x=x+1
step 11: go to new line
step 12: n=n-1
step 13: stop
-0>-1>
main()
step 1: start
step 2: read num,rows
step 3: call pyramid(row,num)
step 4: stop
#include
void space(int i)
{
while(i>=0)
{
printf(" ");
i--;
}
}
void pyramid (int n,int num)
{
int i,x=1;
while(n>0)
{
space(n);
for(i=0;i
printf(" %d",num);
x++;
printf("\n");
n--;
}
}
void main()
{
int rows, num;
clrscr();
printf("\nEnter the a digit : ");
scanf("%d",&num);
printf("\nEnter the number of rows (less than 35) : ");
scanf("%d",&rows);
printf("\n\n");
pyramid(rows,num);
getch();
}
Algorithm
space(i)
step 1: start
step 2: check whether i>=0,then go to step 3
else go to step 5
step 3: print " "
step 4: i=i-1
step 5: stop
pyramid(n,num)
step 1: start
step 2: intilize x<-1 br="">step 3: check whether n>0 then go to step 4
else go to step13
step 4 : Call space(n)
step 5: intilize i<-0 br="">step 6: check whether i
step 7: print num
step 8: i=i+1
step 9: go to step 8
step 10: x=x+1
step 11: go to new line
step 12: n=n-1
step 13: stop
main()
step 1: start
step 2: read num,rows
step 3: call pyramid(row,num)
step 4: stop