patternprogram_32 softethics

Pattern 32

C

#include <stdio.h>

int main()
{
  int n = 5;
  int i,j,x;
  for(i = 0; i < n; i++)
  {
    x = i;
    for(j = 1; j <= n; j++)
    {
      x += n;
      printf("%c ", x - n + 65);
    }
    printf("\n");
  }
  return 0;
}

C++

#include <iostream.h>

int main()
{
  int n = 5;
  int x;
  for(int i = 0; i < n; i++)
  {
    x = i;
    for(int j = 1; j <= n; j++)
    {
      x += n;
      cout<<(char)(x - n + 65)<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Java

  class PatternProg
  {
  public static void main(String args[])
  {
    int n = 5;
    int x;
    for (int i = 0; i < n; i++)
    {
      x = i;
      for (int j = 1; j <= n; j++)
      {
        x += n;
        System.out.print((char)(x - n + 65)+" ");
      }
      System.out.println();
    }

  }
}

C#

using System;

class PatternProg
{
  public static void Main()
  {
    int n = 5;
    int x;
    for (int i = 0; i < n; i++)
    {
      x = i;
      for (int j = 1; j <= n; j++)
      {
        x += n;
        Console.Write((char)(x - n + 65) + " ");
      }
      Console.WriteLine();
    }
    Console.ReadKey(true);
  }
}

Python

n = 5
ch = 0

for x in range(0, n):
  p1 = x
  for y in range(1, n+1):
    x += n
    print(chr(x - n + 65)+" ",end="")
  print()
5 1 vote
Rate this Program
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments