patternprogram_403 softethics

Pattern 403

C

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

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

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

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

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

    for(k=size; k>=abs(i); k--)
    {
      printf("%c ",p+65);
      p++;
    }
    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