;

C Program to print a full pyramid using an asterisk(*)


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to print a full pyramid using an asterisk(*).

Here is the code of the program to print a full pyramid using an asterisk(*).

Code - C Program to print a full pyramid using an asterisk(*)
/* C Program to print a full pyramid using asterisk(*) */

#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("*");
        }
        l = l + 2;
        printf("\n");
    }
}
Output

Enter number of rows: 5
        *
      ***
    *****
  *******
*********

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


Related Posts



Comments

Recent Posts
Tags