C Program to Print * Pattern in Upside Down Triangle

In this c programming example we will learn how to print triangle * down side

Algorithm

  1. Take input number to how many row need to print
  2. Run an iteration upto given number of rows
  3. Print " "  for in increase order from 1 to n-1 with condition of j<i
  4. Print "*" for in increase order from 1 to n-1 with condition of j<n
  5. Emds the iteration

 

Simple C example to print reverse words in line string

#include <stdio.h>

int main() {
    
   int n,i,j;

   n = 5;

   for(i = 1; i <= n; i++) {
       
      for(j = 1; j < i; j++)
         printf(" "); 

      for(j = i; j <= n; j++)
         printf("* ");

      printf("\n");
   }

   return 0;
}

 

Output

* * * * *  ;

 * * * *;   

  * * *;    

   * *;     

    *   

 

 

Subscribe For Daily Updates