Pattern 20 : Hollow Mirrored right angle triangle pattern program in C using loops
C program to print the following Hollow mirrored triangle star pattern :
Write a C Program to print Hollow mirrored triangle pattern program. The program going to take the number of rows as the input and print the pattern with that many rows. We will use the two for loops to print the program.
Here is the example input and output pattern
Enter Number : 5
*
* *
* *
* *
* * * * *
Few browsers are not showing patterns properly. So here is one screenshot of actual hollow mirrored right triangle.
Hollow mirrored triangle star pattern Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include<stdio.h> int main() { int i,j,n; // Take input from the user printf("Enter how many rows you want: "); scanf("%d",&n); // Outer for loop for rows for(i=1;i<=n;i++) { // To createt the preceding spaces before triangle for(j=1;j<=(n-i);j++) printf(" "); // two spaces // Now print the Triangle pattern for(j=1;j<=i;j++) { // We only need stars at the boarder. Hollow Triangle. if( j==i || j==1|| i==n) printf(" *"); else printf(" "); } printf("\n"); } return 0; } |
Hollow mirrored triangle star pattern Output:
We are using the GCC compiler in Ubuntu operating system.
Output |
You may also like:
- Basic star pattern program (The square pattern with stars).
- Triangle star pattern program.
- Triangle star pattern program with Spaces.
- Pyramid star pattern.
- Reverse Pyramid program.
- Diamond Star pattern program.
- star pattern program.
- K-Star pattern program.
- Empty Rhombus program.
- X-Star pattern program.
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.