/*Write a C program to construct a pyramid of numbers*/
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,n;
clrscr();
printf("Enter pyramid range:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
printf(" ");
for(j=0;j<i;j++)
printf("%d ",i);
printf("\n");
}
getch();
}
#include<conio.h>
main()
{
int i,j,n;
clrscr();
printf("Enter pyramid range:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
printf(" ");
for(j=0;j<i;j++)
printf("%d ",i);
printf("\n");
}
getch();
}
output:
Enter pyramid range:6
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
0 comments:
Post a Comment