Select Page

How to design a mirror right triangle using star Symbol – In this section, we will detail in on the large number of techniques to print a modified mirror right triangle using star symbol in the C program.

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:

  • For Loop
  •  While Loop
  •  Do-While Loop

A miror Right triangle is an extremely regular sort of two-dimensional figure utilized in the field of geometry. It is a sort of a triangle that has one edge equivalent to 90 degrees.

The total of squares of the sides neighboring the correct point is equivalent to the square of the side inverse to the correct edge.

Enter Size: 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.

Mirror Right 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: r=0 and outer loop will be performed as long as r <=n

step 3: c=0

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

step 4.1: check if (c>= n+1-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("\n\tEnter size:");
    scanf("%d",&n);
    printf("\t");
    for(r=0; r<=n; r++)
    {
        for(c=0; c<=n; c++)
{
if(c>=n+1-r) printf("*"); else printf(" "); } printf("\n"); printf("\t"); } }

Mirror Right Triangle Pattern using while Loop

 

int main()
{
    int r,c,n;
    printf("\n\tEnter size:");
    scanf("%d",&n);
    printf("\t");
    r=0;
    while(r<=n)
    {
       c=0;
       while(c<=n)
        {
           if(c>=n+1-r)
               printf("*");
           else
               printf(" ");
         c++;
        }
        r++;
        printf("\n");
        printf("\t");
    }
}

Mirror Right Triangle Pattern using do..while Loop

 

int main()
{
    int r,c,n;
    printf("\n\tEnter size:");
    scanf("%d",&n);
    printf("\t");
    r=0;
    do
    {
      c=0;
      do
      {
          if(c>=n+1-r)
               printf("*");
           else
               printf(" ");
            c++;
      }while(c<=n);

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

Follow me on Facebook