C Program to Print * Pattern in Upside Down Triangle
In this c programming example we will learn how to print triangle * down side
Algorithm
- Take input number to how many row need to print
- Run an iteration upto given number of rows
- Print " " for in increase order from 1 to n-1 with condition of j<i
- Print "*" for in increase order from 1 to n-1 with condition of j<n
- 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
* * * * * ;
* * * *;
* * *;
* *;
*
|