Rectangle number pyramid

Q. Write a C program for print the following number design or number pyramid or number rectangle:

33333
32223
32123
32223
33333

Ans.

To make the above program make module/program and add all module(tips):
Make 3 parts of the design and write down code and at the end, add all parts/module
Figure: How to write above program tips


/*c program for print number rectangle pyramid*/
#include<stdio.h>
int main()
{
 int i,j,k,n=3,r;
 for(j=1; j<=5; j++)
    printf("%d",n);
 printf("\n");
 for(r=1; r<=3; r++)
 {
  for(i=3; i>=2; i--)
    printf("%d", i);
  for(k=n-r; k>=0; k--)
  {
    if(k==0)
      printf("2");
    else
    {
      printf("%d",k);
      break;
    }
  }
  for(i=2; i<=3; i++)
     printf("%d",i);
  printf("\n");
 }
 for(j=1; j<=5; j++)
     printf("%d",n);
 return 0;
}

The output of above program would be:
Output of rectangle number pyramid C program
Screen shot for rectangle number pyramid C program


Comments