Write a program to print the alphabet pattern

A B C D E 
A B C D E 
A B C D E 
A B C D E 
A B C D E 


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 ",in);
   printf("\n");
  }
}


Input/Output:
Enter the row and column size:E
A B C D E
A B C D E
A B C D E
A B C D E
A B C D E

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(in)<<" ";
        cout<<"\n";
}}


Input/Output:
Enter the row and column size:D
A B C D
A B C D
A B C D
A B C D


Write a program to print the pattern in Java.

Code:

import java.util.Scanner;
public class p13 {
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(in+" ");
     System.out.println();
    }
    cs.close();
}
}


Input/Output:
Enter the row and column size:
E
A B C D E 
A B C D E 
A B C D E 
A B C D E 
A B C D E 

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(i),end=" ")
    print("\r")


Input/Output:
Enter the row and column size:
E
A B C D E 
A B C D E 
A B C D E 
A B C D E 
A B C D E 

Post a Comment

0 Comments