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(*).
/* 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");
}
}
Enter number of rows: 5
*
***
*****
*******
*********
--------------------------------
Process exited after 1.621 seconds with return value 5
Press any key to continue . . .
Comments