Write a program to print the alphabet pattern

AAAAA
BBBBB
CCCCC
DDDDD
EEEEE

Write a C program to print the pattern.

Code:

#include<stdio.h>
int main()
{
  printf("Enter the row and column size:");
  int out,in;
  char row_size;
  scanf("%c",&row_size);
  for(out='A';out<=row_size;out++)
  {
   for(in='A';in<=row_size;in++)
    printf("%c",out);
   printf("\n");
  }
}


Input/Output:
Enter the row and column size:E
AAAAA
BBBBB
CCCCC
DDDDD
EEEEE

Write a C++ program to print the pattern 

Code:

#include<iostream>
using namespace std;
int main()
{
  cout<<"Enter the row and column size:";
  int out,in;
  char row_size;
  cin>>row_size;
  for(out='A';out<=row_size;out++)
  {
   for(in='A';in<=row_size;in++)
    cout<<char(out);
        cout<<"\n";
}}


Input/Output:
Enter the row and column size:D
AAAA
BBBB
CCCC
DDDD

Write a program to print the pattern in Java.

Code:

import java.util.Scanner;
public class p12 {

public static void main(String[] args) {

Scanner cs=new Scanner(System.in);    
    System.out.println("Enter the row and column size:");
    char out,in;
    char row_size=cs.next().charAt(0);
    for(out='A';out<=row_size;out++)
    {
     for(in='A';in<=row_size;in++)
     System.out.print(out);
     System.out.println();
    }
    cs.close();
}
}


Input/Output:
Enter the row and column size:
F
AAAAAA
BBBBBB
CCCCCC
DDDDDD
EEEEEE
FFFFFF

Write a PYTHON to print the pattern. 


Code:

print("Enter the row and column size:")
row_size=input()
for out in range(ord('A'),ord(row_size)+1):
    for i in range(ord('A'),ord(row_size)+1):
        print(chr(out),end="")
    print("\r")


Input/Output:
Enter the row and column size:
E
AAAAA
BBBBB
CCCCC
DDDDD
EEEEE

Post a Comment

0 Comments