SUM OF TWO DIMENSIONAL ARRAY OF ELEMENTS


import java.util.Scanner;
class SumofTwoDArray
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("Enter  row and columns of Array");
int x=s.nextInt();
int y=s.nextInt();
int[][] arr=new int[x][y];
for(int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
arr[i][j]=s.nextInt();
    }
}
int sum=0;
for(int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
sum=sum+arr[i][j];
}
}
System.out.println("Sum of Array:"+sum);
}
}

Comments

Popular posts from this blog

Problem Statement Of Real Estate Use Cases

Problem Statement Of Bank Marketing analysis

Hadoop