C program to print reverse right triangle star pattern

Write a C program to print reverse/inverted right triangle star(*) pattern series using for loop. How to print reverse/inverted right triangle star pattern series of n rows using for loop in C programming. Logic to print inverted right triangle star pattern in C program.

Example

Input

Input rows: 5

Output

Required knowledge

Basic C programming, For loop

Must know - Program to print right triangle star pattern

Program to print inverted right triangle star pattern

/**
 * Reverse right triangle star pattern program in C
 */

#include <stdio.h>

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

    // Input number of rows from user
    printf("Enter number of rows : ");
    scanf("%d", &n);

    for(i=1; i<=n; i++)
    {
        for(j=i; j<=n; j++)
        {
            printf("*");
        }
       
        // Move to the next line/row
        printf("\n");
    }

    return 0;
}

Output

Enter number of rows: 5
*****
****
***
**
*

Happy coding 😉

Write your doubts or suggestion. I will try my best to help. You must escape source code before commenting. To format your source code paste your source code inside
<pre><code> ----Your Source Code---- </code></pre>