Skip to content
Home » Half pyramid star pattern in C

Half pyramid star pattern in C

Learn about Half pyramid star pattern using both increment and decrement operators 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.

Half pyramid star pattern in C

Print the pattern given below using C

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

Program:

#include<stdio.h>
int main()
{
  for(int i=5; i>=1; i--)
  {
    for(int j=i; j<=5; j++)
    {
      printf("* "); 
    }

    printf("\n"); 
  }

  return 0;
}

Output:

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

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Pyramid Star Pattern in C
Pascal Triangle in C using 2d Array