## 10.12.2015

### 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:
**********************************************************/

 Figure: Screen shot for Continuous Rhombus Number Pattern C Program

You might also like to read:

1. Hello!I'd like to share my code:

#include
int main(void)
{
int i,j;
for(i=0;i<4;i++)
{
if(i%2)
{
for(j=4;j>0;j--)
printf("%3d",4*i+j);
printf("\n");
}
else
{
for(j=1;j<=4;j++)
printf("%3d",4*i+j);
printf("\n");
}
}
return 0;
}

Can I make friends with you?