Pattern 4 : C program to print Pyramid star pattern

Spread the love
Pattern 4: Write a C Program to print below pattern ( Pyramid Star pattern with spaces).

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

Explanation :

This program is very similar to our last program i.e Triangle Star pattern. The main difference between these two programs is Spaces. By adjusting the spaces, we will get different types of patterns in C programming so try to play with these programs.

Program : 

  1. #include<stdio.h>
  2. int main()
  3. {
  4.    int i,j,n;
  5.    printf(“Enter how many rows you want: “);
  6.    scanf(“%d”,&n);
  7.    for(i=1;i<=n;i++)
  8.    {
  9.       for(j=1;j<=(ni);j++)
  10.          printf(” “);   // Only one space
  11.       for(j=1;j<=i;j++)
  12.          printf(“* “);  // one star and one space
  13.       printf(n);
  14.    }
  15.    return 0;
  16. }

Output:

Output of Pyramid Pattern program

Similar Star pattern programs:

More C programs :

C Tutorials with simple Examples:

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply