PROGRAM-5

// Program to print a pyramid
#include
#include
void main()
{
int n,row=1,col=40,i=0,j,k=0,count=1;
int a[10];
clrscr();
i=n-1;
printf("Pyramid of how many numbers?");
scanf("%d",&n);
for (j=0;j=1;row--)
{
k=0;
k=40-(4*(row-1));
i=row-1;
for (col=40;col>=k;col=(col-4))
{
gotoxy(col,row);
printf("%d",a[i]);
--i;
}
}

for (count=n;count>=1;count--)
{
k=0;
k=40+(4*(count-1));
i=count-1;
for (col=40;col<=k;col=(col+4)) { gotoxy(col,count); printf("%d",a[i]); --i; } } getch(); } Algorithm • Start • Declare n, row=1, col=40 ,i=0, j, k=0, count=1 as integer • Declare a[10] as integer • i=n-1 • Write("Pyramid of how many numbers?") • Read(“Pyramid of how many numbers?”) • for (j=0;j=1;row--)
k=0
k=40-(4*(row-1))
i=row-1
• for (col=40;col>=k;col=(col-4))
• gotoxy(col,row)
• Read(“a[i]”)
• --i
• for (count=n;count>=1;count--)
k=0
k=40+(4*(count-1))
i=count-1
• for (col=40;col<=k;col=(col+4))
• gotoxy(col,count);
• Read(“a[i]”)
• --i
• Stop




#vpsinghrajput

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment