Number Pattern Program in C - 53


c program for pattern


/*
Write a program in C for Number Pattern Program
*/

int main()
{
  int i,j,k,l;
  for(k=i=1;i<=5;i++)
  {
    l=k+i-1;
    for(j=1;j<=i;j++)
    {
      if(i%2==1)
        printf("%d ",k);
      else
        printf("%d ",l);
      k++;
      l--;
    }
    printf("\n");
  }
  return 0;
}

Post a Comment

0 Comments