Pattern 3 :C Program to print Star pattern | Triangle star pattern program.
Introduction:
Let’s write a C Program to print the Reverse Triangle pattern (star). This pattern contains the stars and spaces. It is right angle triangle.
This program asks for input from the user. Depending on the input, It will print the triangle upto that size. For example, If the user input is 5. Then it will print the triangle upto the five rows, Starting from row one.
In the row 1, It will print one star, In the row 2 it will print two stars, So on. At the row 5 it will print 5 stars. Here is the pattern for input value of 5.
Pattern 3 : Write a C Program to print below pattern ( Triangle Star pattern with spaces).
* *
* * *
* * * *
* * * * *
Reverse Triangle 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(j=1;j<=(n–i);j++)
-
printf(” “); // two spaces
-
-
for(j=1;j<=i;j++)
-
printf(” *”);
-
-
printf(“\n“);
-
}
-
return 0;
-
}
Output :
Output of star pattern program |
Similar Star pattern programs:
Also See:
- 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.
1 Response
[…] Pattern 3: Reverse Triangle Star Pattern Program […]