C Program to display Inverted half-pyramid using *

Problem

Write a program in C to print Inverted half-pyramid using * as shown below.The program should take the number of rows as input.

* * * *
* * *
* *
*

How to create and display Inverted half-pyramid pattern in C using * ?

#include <stdio.h>
int main()
{
    int index1, index2, input;
    printf("Abundantcode.com Coding samples\n");
    printf("Enter the limit : ");
    scanf("%%d",&input);

    for(index1=input; index1>=1; --index1)
    {
        for(index2=1; index2<=index1; ++index2)
        {
            printf("* ");
        }
        printf("\n");
    }
    
    return 0;
}

Output

Abundantcode.com Coding samples

Enter the limit : 4

* * * *

* * *

* *          
*