Contact Learn C
Copy Program Share Program

Program 36: Number Diamond Pattern

Program 36:
 
//   1
//  123
// 12345
//1234567
// 12345
//  123
//   1
#include<stdio.h>
main()
{
  int i,j,k,count,number;
  printf("Enter number of rows till 5\n");
  scanf("%d",&number);
  count=number-1;
  for(i=1;i<=2*(number)-1;i+=2)
  {
   for(k=1;k<=count;k++)
    {
     printf(" ");
    }
   count--;
   for(j=1;j<=i;j++)
   {
    printf("%d",j);
   }
   printf("\n");
  }
  count=1;
  for(i=2*(number)-1;i>=1;i-=2)
  {
   if(i!=(2*(number)-1))
   {
    for(k=1;k<=count;k++)
    {
     printf(" ");
    }
    count++;
    for(j=1;j<=i;j++)
    {
     printf("%d",j);
    }
    printf("\n");
   }
  }
}
Explanation:

//Coming Soon...

 Output:

Number Diamond Pattern

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide