0% found this document useful (0 votes)
4 views

Import Java - Copy

This Java program prompts the user to input the number of rows and columns for a matrix. It then allows the user to enter the elements of the matrix and prints the resulting array. The program utilizes nested loops for both input and output of the matrix elements.

Uploaded by

neelamsahun41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Import Java - Copy

This Java program prompts the user to input the number of rows and columns for a matrix. It then allows the user to enter the elements of the matrix and prints the resulting array. The program utilizes nested loops for both input and output of the matrix elements.

Uploaded by

neelamsahun41
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

*;

public class matrix

public static void main (String args[])

Scanner br= new Scanner (System.in);

System.out.println("Enter the no of rows");

int row=br.nextInt();

System.out.println("Enter the no of columns ");

int col=br.nextInt();

int a [] []= new int[row] [col];

//input array elements

System.out.println("Enter"+(row*col)+ "Array Elements");

for (int i=0;i<row;i++)

for (int j=0;j<col;j++)

a[i][j]=br.nextInt();

// Print the array elements

System.out.println("The array is :\n");

for(int i=0;i<row;i++)

{
for(int j=0;j<col;j++)

System.out.print(a[i][j]+" ");

System.out.println();

You might also like