Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

Continuous Rhombus Number Pattern

Q. Write a Number reverse program in C language as following pattern:

     1  2  3  4
     8  7  6  5
     9 10 11 12
    16 15 14 13

Ans.

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

 int r,c,p;
 for(r=1; r<=4; r++)
 {
   if(r%2==0)
   {
      if(r==2)
      {
        for(c=1,p=8; c<=4; c++,p--)
            printf(" %d", p);
      }
      else
      {
        for(c=1,p=16; c<=4; c++,p--)
            printf(" %d", p);
      }
   }
   else
   {
      if(r==1)
      {
        for(c=1; c<=4; c++)
            printf(" %d", c);
      }
      else
      {
        for(c=1,p=9; c<=4; c++,p++)
            printf(" %d", p);
      }
   }
   printf("\n");
 }
 getch();
 return 0;
}

/*************************************************************

The output of above Continuous Rhombus Number Pattern program would be:
**********************************************************/

Output of Continuous Rhombus Number Pattern C Program
Figure: Screen shot for Continuous Rhombus Number Pattern
C Program

You might also like to read:

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




0 komentar:

Post a Comment

Continuous Rhombus Number Pattern