C Program to Print Reversed Mirrored Right Triangle

How to write a C Program to Print Reversed Mirrored Right Triangle Star Pattern with example?. And also show you how to print Reversed Mirrored Right Triangle Pattern with different symbols.

C Program to Print Reversed Mirrored Right Triangle

This C program allows the user to enter the maximum number of rows he/she want to print as Reversed Mirrored Right Triangle. We are going to print the * symbols until it reaches the user-specified rows.

/* C Program to Print Reversed Mirrored Right Triangle Star Pattern */
#include <stdio.h>
 
int main() 
{
  int Rows, i, j;
	
  printf("Please Enter the Number of Rows:  ");
  scanf("%d", &Rows);
	
  printf("\nPrinting Reversed Mirrored Right Triangle Star Pattern \n");
  for ( i = 1 ; i <= Rows; i++ ) 
  {
      for ( j = 1 ; j <= Rows; j++ ) 
      {
      	if(j < i)
      	{
          printf(" ");
	}
	else
	{
	  printf("*");		  	
	}         
      }
      printf("\n");
  }
  return 0;
}
C Program to Print Reversed Mirrored Right Triangle Star Pattern 1

Let us see the Nested for loop

Outer Loop – First Iteration

From the above screenshot, you can observe that the value of i is 1 and Rows is 6 so, the C Programming condition (i <= 6) is True. So, it will enter into second for loop

Inner Loop – First Iteration: The j value is 1 and the condition (j <= 6) is True. So, it will start executing the statements inside the loop. So, it will enter into the If Statement. Here, we are checking whether j < i (1 < 1) . If this condition is true, then printf(” “) will be executed. Otherwise, printf(“*”) will execute.

It will happen until the condition inside the inner for loop fails. Next, iteration will start from the beginning until both the Inner Loop and Outer loop conditions fail.

C Program to return Reversed Mirrored Right Triangle

This program to print reverse mirrored right triangle allows the user to enter the Symbol and number of rows he/she want to print. It means, instead of printing pre-defined stars, it allows the user to enter their own character.

/* C Program to Print Reversed Mirrored Right Triangle Star Pattern */
#include <stdio.h>
 
int main() 
{
  int Rows, i, j;
  char Ch;
  
  printf("Please Enter any Symbol :   ");
  scanf("%c", &Ch); 
  	
  printf("Please Enter the Number of Rows:  ");
  scanf("%d", &Rows);
	
  printf("\nPrinting Reversed Mirrored Right Triangle Star Pattern \n");
  for ( i = 1 ; i <= Rows; i++ ) 
  {
      for ( j = 1 ; j <= Rows; j++ ) 
      {
      	if(j < i)
      	{
          printf(" ");
	}
	else
	{
	  printf("%c", Ch);		  	
	}         
      }
      printf("\n");
  }
  return 0;
}
Please Enter any Symbol :   $
Please Enter the Number of Rows:  10

Printing Reversed Mirrored Right Triangle Star Pattern 
$$$$$$$$$$
 $$$$$$$$$
  $$$$$$$$
   $$$$$$$
    $$$$$$
     $$$$$
      $$$$
       $$$
        $$
         $

C Program to return Reversed Mirrored Right Triangle using While Loop

In this C program, we just replaced the For Loop with the While Loop. I suggest you refer to While Loop article to understand the logic.

/* C Program for Reversed Mirrored Right Triangle Star Pattern */
#include <stdio.h>
 
int main() 
{
  int Rows, i = 1, j;
  char Ch;
  
  printf("Please Enter any Symbol :   ");
  scanf("%c", &Ch); 
  	
  printf("Please Enter the Number of Rows:  ");
  scanf("%d", &Rows);
	
  printf("\nPrinting Reversed Mirrored Right Triangle Star Pattern \n");
  while( i <= Rows ) 
  {
      for ( j = 1 ; j <= Rows; j++ ) 
      {
      	if(j < i)
      	{
          printf(" ");
	}
	else
	{
	  printf("%c", Ch);		  	
	}         
      }
      printf("\n");
      i++;
  }
  return 0;
}
Please Enter any Symbol :   #
Please Enter the Number of Rows:  9

Printing Reversed Mirrored Right Triangle Star Pattern 
#########
 ########
  #######
   ######
    #####
     ####
      ###
       ##
        #