patternprogram_213 softethics

Pattern 213

C

#include<stdio.h>

int main()
{
  int i,j;

  for (i=0; i<4; i++)
  {
    for (j=i; j<i+4; j++)
    {
      printf("%c",(j%4)+65);
    }
    printf("\n");
  }
  return 0;
}

C++

#include<iostream.h>

int main()
{
    int i,j;

    for (i=0; i<4; i++)
    {
        for (j=i; j<i+4; j++)
        {
            cout<<char((j%4)+65);
        }
        cout<<endl;
    }
    return 0;
}

Java

  class PatternProg
  {
    public static void main(String args[])
    {
        for (int i = 0; i < 4; i++)
        {
            for (int j = i; j < i + 4; j++)
            {
                System.out.print((char)((j % 4) + 65));
            }
            System.out.println();
        }

    }
}

C#

using System;

class PatternProg
{
  public static void Main()
  {
    for (int i = 0; i < 4; i++)
    {
      for (int j = i; j < i + 4; j++)
      {
        Console.Write((char)((j % 4) + 65));
      }
      Console.WriteLine();
    }
    Console.ReadKey(true);
  }
}

Python

for x in range(0, 4):
    for y in range(x, x+4):
      print(chr((y%4)+65), end="")
    print()

"""
65 > ASCII of 'A'
"""
0 0 votes
Rate this Program
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments