Learn about C program to print Full pyramid star pattern in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C program to print Full pyramid star pattern
To print a full pyramid like below in C then run the below C program. Full can print a larger pyramid by changing the number of rows.
* *** ***** ******* *********
Program:
#include<stdio.h>
int main()
{
int n;
printf("Enter number of rows: ");
scanf("%d",&n);
for(int i=1; i<=n; i++)
{
for(int j=1; j <= n-i; j++)
printf(" ");
for(int k=1; k <= (2*i-1); k++)
printf("*");
printf("\n");
}
return 0;
}
Output:
Enter number of rows: 5 * *** ***** ******* *********
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
Inverted half pyramid star pattern in C
Half pyramid star pattern using both increment and decrement operators in C