Select Page

How to write the Right Angle Triangle Pattern using star symbol in C program – In this article, we will brief in on the various way to print a correct triangle star design in C programming.

Appropriate models and test programs have likewise been included with the goal that you can comprehend the entire thing obviously. The compiler has likewise been included with which you can execute it yourself.

The following Pattern program is written in three unique manners:

• Utilizing For Loop
• Utilizing While Loop
• Utilizing Do-While Loop

It’s anything but another thing to the universe of coders what a Right Triangle is. It is a sort of a triangle that has one edge equivalent to 90 degrees.

The entirety of squares of the sides contiguous the correct edge is equivalent to the square of the side inverse to the correct edge.

Enter No: 5 According to the above Pattern number of rows specified 5 and the number of Columns specified also 5.

The Star Symbol(‘*’) is picked to do the distinctions according to the name of the title itself.

## Right Angle Triangle Pattern using For Loop

### Algorithm

Input: Let, three variables say r,c,n. The value of n will be given by the user.

step 1: Input values for n

step 2: outer loop will be performed as long as r < n

step 3: c=1

step 4: inner loop will be performed as long as  c < n

step 4.1: check if (c<= r ) is true then

print symbol star (‘*’)

else

print  “blank space”

step 5: j=j+1

step 6: End inner loop

step 7: next line start

step 8: i= i+1

step 9:  End outer loop

### Source Code

```int main()
{
int r,c,n;
printf("ntEnter no:");
scanf("%d",&n);
printf("\t");
for(r=0; r<n; r++)
{
for(c=0; c<n; c++)
{
if(c<=r)
printf("*");
else
printf(" ");
}
printf("\n");
printf("\t");
}
}
```

## Right Angle Triangle Pattern using While Loop

```int main()
{
int r,c,n;
printf("ntEnter no:");
scanf("%d",&n);
printf("\t");
r=0;
while(r<n)
{
c=0;
while(c<n)
{
if(c<=r)
printf("*");
else
printf(" ");
c++;
}
r++;
printf("\n");
printf("\t");
}
}
``` ## Right Angle Triangle Pattern using do..while Loop

```int main()
{
int r,c,n;
printf("ntEnter no:");
scanf("%d",&n);
printf("\t");
r=0;
do
{
c=0;
do
{
if(c<=r)
printf("*");
else
printf(" ");
c++;
}while(c<n);

r++;
printf("\n");
printf("\t");
} while(r<n);
}

``` 