C PROGRAM TO PRINT NUMBERS IN PYRAMID FORM


/*PROGRAM TO PRINT NUMBERS IN PYRAMID FORM */
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k=1,n,m,l=1,p=1;
printf("\n ENTER THE NUMBER OF ROWS : ");
scanf("%d",&n);
m=n;
for(i=n;i>0;i--)
{
for(j=0;j<i;j++)
printf("   ");
for(p=0;p<l;p++)
{
printf("%3d",k);
k++;
}
l=l+2;
printf("\n");
}
getch();
}


OUTPUT

 ENTER THE NUMBER OF ROWS : 5
                 1
              2  3  4
           5  6  7  8  9
       10 11 12 13 14 15 16
    17 18 19 20 21 22 23 24 25

For more C programs - click here

Popular posts from this blog

Mini Militia Chat Codes - Shortforms

8051 Assembly Program Code for Sorting in Ascending Order - Keil -AT89C51