recent

Write a c program to print given number pattern

Write a c program to print given number pattern
1
2 3 2
4 5 6 5 4
7 8 9 1 0 9 8 7
11 12 13 14 15 14 13 12 11


#include<stdio.h>
int main()
{
  int i,m,k=1,j=1,n=5;
  for(i=1;i<=n;i++)
  {
    j=k;
    for(m=1;m<=i;m++)
      printf("%d ",j++);
    k=j--;
    for(m=1;m<i;m++)
      printf("%d ",--j);
    printf("\n");
  }
}
Powered by Blogger.