patternprogram_400 softethics

Pattern 400

C

#include<stdio.h>
#include<math.h>

int main()
{
  int size=4;
  int i,j,k;
  int p=1;

  for(i=size; i>=-size; i--)
  {
    for(j=1; j<=abs(i); j++)
    {
      printf(" ");
    }

    /*initialize p with 1 (i>=0) or j */

    p=(i>=0)?1:j;

    for(k=size; k>=abs(i); k--)
    {
      printf("%d ",p);
      p++;
    }
    printf("\n");
  }
  return 0;
}

C++

Java

C#

Python

5 1 vote
Rate this Program
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
reCaptcha Error: grecaptcha is not defined