C Program to display full pyramid using *

Problem

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

        *
      * * *
    * * * * *
  * * * * * * *

How to create and  display full pyramid pattern in C using * ?

#include <stdio.h>
int main()
{
    int index1, index2, n, index3=0;
    printf("Abundantcode.com Coding samples\n");
    printf("Enter the limit: ");
    scanf("%d",&n);
    for(index1=1; index1<=n; ++index1, index3=0)
    {
        for(index2=1; index2<=n-index1; ++index2)
        {
            printf("  ");
        }

        while(index3 != 2*index1-1)
        {
            printf("* ");
            ++index3;
        }
        printf("\n");
    }
    
    return 0;
}

Output

Abundantcode.com Coding samples

Enter the limit: 4

      *

    * * *

  * * * * *

* * * * * * *