patternprogram_302 softethics

Pattern 302

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); // to get character
      else
        printf("%d",j);
    }
    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