patternprogram_154 softethics

Pattern 154

C

#include<stdio.h>   // header file


int main()
{
  int i,j,k=1;
  int n=3;//size
  int x=1,z;
  int g;

  for(i=0; i<n; i++)
  {

    for(z=n-1; z>=i; z--)
    {
      printf("  ");
    }

    for(j=0; j<k; j++)
    {
      if(i==j)
      {
        g=(x+1)*(j+j);
        g=(g==0)?1:g;
        printf(" %d",g);
        continue;
      }
      x+=2;
      printf(" %d",x);
    }
    k+=2;
    printf("\n");
  }

}

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