diff --git a/implementation of 2D array in java b/implementation of 2D array in java new file mode 100644 index 0000000..4133a2d --- /dev/null +++ b/implementation of 2D array in java @@ -0,0 +1,65 @@ +;package practice; +import java.util.Scanner; + +public class twoDsummation { + + public static void main(String[] args) { + // TODO Auto-generated method stub + Scanner s = new Scanner(System.in); + + int a[][] = new int[2][3]; + int b[][] = new int[2][3]; + int c[][] = new int[2][3]; + + System.out.println("enter first array "); + + for(int i=0;i<2;i++) { + for(int j=0;j<3;j++) { + a[i][j]= s.nextInt(); + } + } + + + System.out.println("enter second array "); + for(int i=0;i<2;i++) { + for(int j=0;j<3;j++) { + b[i][j]= s.nextInt(); + } + } + System.out.println("first array is: "); + for(int i=0;i<2;i++) { + for(int j=0;j<3;j++) { + System.out.print(a[i][j]); + System.out.print(" "); + } + System.out.println("\n"); + } + + System.out.println("second array is: "); + for(int i=0;i<2;i++) { + for(int j=0;j<3;j++) { + System.out.print(b[i][j]); + System.out.print(" "); + } + System.out.println("\n"); + } + + System.out.println("sum of array a[][] and b[][]"); + for(int i=0;i<2;i++) { + for(int j=0;j<3;j++) { + c[i][j]= a[i][j]+b[i][j]; + } + } + + for(int i=0;i<2;i++) { + for(int j=0;j<3;j++) { + System.out.print(c[i][j]); + System.out.print(" "); + } + System.out.println("\n"); + } + + + } + +}