Sunday 6 January 2019

Filled Under:

Pyramid Of Numbers With C[c programming examples with output]

C programming examples with output

Pyramid Of Numbers
Program

#include<stdio.h>
#include<conio.h>
main()
{
     int rows,t,i,j,k,s;
     clrscr();
     printf("Enter no.of rows to print : ");
     scanf("%d",&rows);
     t=1;
    for(i=1;i<=rows;i++)
    {
        for(j=0;j<(rows-i);j++)
        printf(" ");
        s=(2*i)-1;
            for(k=0;k<s;k++)
       {
            if(t<10)
            printf("%d ",t);
            else
            printf("%d ",t);
            t++;
       }
           printf("\n\n");
    }
    getch();
}

Output:
Enter no, of rows to print: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

0 komentar:

Post a Comment