;

C Program to Print a Full Pyramid using Digits


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to print a full pyramid using digits.

Here is the code of the program to print a full pyramid using digits.

Code - C Program to Print a Full Pyramid using Digits
/* C Program to Print a Full Pyramid using Digits
          1
         123
        12345
       1234567
      123456789
 */

#include <stdio.h>

void main() {
    int a = 0, b = 0, c = 0, l = 1, rows = 0;

    printf("Enter number of rows:\t");
    scanf("%d", & rows);

    for (a = 1; a <= rows; a++) {
        for (b = 10; b >= a; b--) {
            printf(" ");
        }

        for (c = 1; c <= l; c++) {
            printf("%d", c);
        }
        l = l + 2;
        printf("\n");
    }
}
Output

Enter number of rows: 5
         1
       123
     12345
   1234567
123456789

--------------------------------
Process exited after 1.748 seconds with return value 5
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags