Skip to content
Home » Full pyramid star pattern at center in C

Full pyramid star pattern at center in C

Learn about Full pyramid star pattern at the center of the screen in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Full pyramid star pattern at the center of the screen in C

                                       *
                                      ***
                                     *****
                                    *******
                                   *********

Program:

#include<stdio.h>
int main()
{
   int n, c=80;

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

   for(int i=1; i<=n; i++)
   {
     for(int j=1; j<=(c/2-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 :
C program to print Full pyramid star pattern
Inverted half pyramid star pattern in C