patternprogram_308 softethics

Pattern 308

C

#include <stdio.h>
int main()
{
  int n=5; //size
  int i,j,s;

  for(i=1; i<=n; i++)
  {
    for(s=n-1; s>=i; s--)
    {
      printf(" ");
    }
    for(j=1; j<=i; j++)
    {
      if(i%2!=0)
        printf("%c ",j+64);// whitespace after %c
      else
        printf("%d ",j); // whitespace after %d
    }
    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