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 :
-
#include<stdio.h>
-
int main()
-
{
-
int i,j,n;
-
printf(“Enter how many rows you want: “);
-
scanf(“%d”,&n);
-
for(i=1;i<=n;i++) // for loop 1
-
{
-
for(j=1;j<=(n–i);j++) // for loop 2
-
printf(” “); // one space only
-
for(j=1;j<=i;j++) // for loop 3
-
printf(“*”);
-
for(j=1; j<i ; j++) // for loop 4
-
printf(“*”);
-
printf(“\n“);
-
} // outer for loop, for rows
-
return 0;
-
}
Output:
Pyramid Pattern program without spaces |
Similar Star pattern programs:
- Basic star pattern program (The square pattern with stars).
- Triangle star pattern program.
- Triangle star pattern program with Spaces.
More C programs:
- Program to calculate Maximum of three numbers.
- What are Prime Number and C program to Check given number is Prime or Not
- Check given Number is Prime or not Using Square Root(sqrt) Function.(Efficient way)
- C Program to generate prime numbers between two numbers
- C Program to generate first N prime numbers.
- C program to Calculate percentage of student.
- C Program to check given year is the leap or not.
- C Program to convert Temperature.
- C program to understand type conversation.
- Finding Largest of two numbers using the conditional operator in C.
- C program to calculate the simple Interest,
- C program to understand Size of Operator.
- 200+ C Programs.
C Tutorials with simple Examples:
- Arithmetic Operators with Examples.
- Arithmetic operators priority and it’s Associativity.
- Modulus Operator and Hidden Concepts of Modulus Operator.
- Precedence Table or Operators Priority Table.
- Assignment Operator, Usage, Examples
- Increment Operator and Different types of Increment operators Usage with Examples.
- Decrement Operator and Different types of Decrement operators with Examples.
- Logical or Boolean Operators.