patternprogram_253 softethics

Pattern 253

C

#include <stdio.h>

int main()
{
  int n = 5;
  int i,j;

  int px = 1, py = 1, t;

  for(i = 1; i <= n; i++)
  {
    t = py;
    for(j = 1; j <= i; j++)
    {
      if (i % 2 == 1)
      {
        printf("%2d ", px);
      }
      else
      {
        printf("%2d ", t);
      }
      t--;
      px++;

      if (j != i)
        printf("* ");
    }
    py = py + i + 1;
    printf("\n");
  }
  return 0;
}

C++

Java

C#

Python

0 0 votes
Rate this Program
Subscribe
Notify of
guest


0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments