Pattern 5 : Pyramid star pattern program in C | C Program to print pyramid star pattern

Pyramid star pattern Program in C:

Write a c program to print the pyramid start pattern. We are going to use the for loops to create the pattern.

Pattern 5: Write a C Program to print below pattern ( Pyramid Star pattern without spaces).

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

Pyramid Pattern Explanation:

I am using four for loops to print above pattern. First for loop is responsible for number of rows. I also divided this pattern into three parts as shown in below image. And remaining three inner for loops are responsible for printing these three parts.

We also discussed another way to create Pyramid Pattern in the following article – Pattern 4 : C program to print Pyramid star pattern – SillyCodes

Pyramid Star Pattern 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++)       // for loop 1
  8. {
  9. for(j=1;j<=(ni);j++)   // for loop 2
  10. printf(” “);   // one space only 
  11. for(j=1;j<=i;j++)      // for loop 3
  12. printf(“*”);
  13. for(j=1; j<; j++)    // for loop 4
  14. printf(“*”);
  15. printf(“\n);
  16. } // outer for loop, for rows
  17. return 0;
  18. }

Output:

Pyramid-star-pattern-program-in-c-programming-language
Pyramid Pattern program without spaces

Similar Star pattern programs:

More C programs:

C Tutorials with simple Examples:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

Leave a Reply