Print number pyramid pattern - C Program

Write a program to print following output:
input number pyramid

Solution:

#include<stdio.h>
int main()
{
      int i,a,b;
      for(a=5, b=1; b<=5;a--,b++) // Here, a>=1 condition is optional. We  can use either a>=1 or b<=5.
      {
            for(i=1;i<a;i++)
            printf(" ");
            for(i=1;i<=b;i++)
            printf("%d ",i);
            printf("\n");
      }
      return 0;
}


Output:

number pyramid pattern