New Want to Write for Computaholics ? if Yes Contact us at "contact@computaholics.in"

c program to print given number pattern

Write a c program to print given number pattern
1
3 2
4 5 6
10 9 8 7
11 12 13 14 15
21 20 19 18 17 16

#include<stdio.h>

int main()
{
  int i,m,n,p;
  for(n=i=1;i<=6;i++)
  {
    p=n+i-1;
    for(m=1;m<=i;m++)
    {
      if(i%2==1)
        printf("%d ",n);
      else
        printf("%d ",p);
      n++;
      p--;
    }
    printf("\n");
  }
}
Copyright © C Program | Java | OpenGL Programming | Hadoop at Computaholics