1.17.2017

Number Rhombus Pattern C Program

Q. Write a C program to print the following number rhombus pattern as:

    ********
    ***22***
    **2222**
    *222222*
    22222222
    *222222*
    **2222**
    ***22***
    ********

Ans.

/* c program for number rhombus pattern source code*/
#include<stdio.h>
int main()
{

 int num=3,r,c,x,y,z,sp;
 printf("******\n");
 for(r=1; r<=num; r++)
 {
   for(sp=num-r; sp>=1; sp--)
       printf("*");
   for(c=1; c<=r; c++)
       printf("2");
   for(c=r; c>=1; c--)
       printf("2");
   for(c=num-r; c>=1; c--)
       printf("*");

   printf("\n");
 }
for(r=1; r<num; r++)
 {
   for(sp=r; sp>=1; sp--)
       printf("*");
   for(c=1; c<=(num-r); c++)
       printf("2");
   for(c=num-r; c>=1; c--)
       printf("2");
   for(c=1; c<=r; c++)
       printf("*");
   printf("\n");

 }
 printf("******\n");
 getch();
 return 0;
}


/*************************************
The output of above Number Rhombus Pattern C Program would be:
**************************************/
Output of Number Rhombus Pattern C Program
Figure: Screen shot for Number Rhombus Pattern C Program


You might also like to read:

  1. Big list of 98+ C Pyramid Programs
  2. Latest user asking pyramid programs list

2 comments: