Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create 2D Array Addition #243

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions 2D Array Addition
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.util.Scanner;

public class Arry2DAdd {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of array:");
int size=sc.nextInt();
int num1[][]=new int[size][size];
int num2[][]=new int[size][size];
System.out.println("Enter numbers in array:");
for(int i=0;i<size;i++){
for(int j=0;j<size;j++) {
num1[i][j]=sc.nextInt();
num2[i][j]=sc.nextInt();
}
}
System.out.println("Resultant Matrix:");
for(int i=0;i<size;i++){
for(int j=0;j<size;j++) {
System.out.print(" ");
System.out.print(num1[i][j]+num2[i][j]);
}
System.out.println();
}

}

}