Skip to content
Home » C program to print inverted full pyramid star pattern

C program to print inverted full pyramid star pattern

Learn about C program to print inverted 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.

C program to print inverted full pyramid star pattern

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

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< 2*n; j++)
    {
        if(j<i) 
        printf(" "); 

        else if(j <= 2*n-i) 
        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 :
Full pyramid star pattern at the center of the screen in C
C program to print Full pyramid star pattern