Print mixed right angle triangle pattern - C

Write a program to print following output:

input mixed right angle triangle

Solution:

For printing above output, first divide the above input into two parts. i.e (Binded Right Triangle and Inverted Right Angle Triangle)

input image                           input image

#include<stdio.h>
int main()
{
      int i,a,b;
      for(a=5, b=1; b<=5;a--,b++) // This loop to print part-1 output
      {
            for(i=1;i<b;i++)
            printf(" ");
            for(i=1;i<=a;i++)
            printf("%d",i);
            printf("\n");
      }
      for(a=4, b=2; b<=5;a--,b++) // This loop is to print part-2 output
      {
            for(i=1;i<a;i++)
            printf(" ");
            for(i=1;i<=b;i++)
            printf("%d",i);
            printf("\n");
      }
      return 0;
}


Output:

mixed right angle triangle