Pattern-12

 Pattern12


C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int numbers,i,j;
    char c='A';
    printf("Enter the Number of rows:");
    scanf("%d",&numbers);
    for(i =0 ; i<numbers; i++)
     {
       for(j=0; j<numbers ; j++)
       {
        printf("%c ",c);
        c++;

       }
        printf("\n");
         c='A';
     }
}



Java Program
import java.util.Scanner;

public class Pattern_12 {

	public static void main(String[] args) {
		Scanner S = new Scanner(System.in);
		System.out.print("Enter Number of Rows:");
		int n = S.nextInt();
		char c = 'A';
		for(int i=0; i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				System.out.print(c + " ");
				c++;
			}
			System.out.print("\n");
			c='A';
		}
	}

}


Python Program
n = int(input("Enter numbe of rows: "))

for i in range(n):
    a=65
    for j in range(n):
        print(chr(a), end=" ")
        a=a+1
    print(" ")

0 Comments:

Post a Comment