answersLogoWhite

0

import java.util.Scanner; class Addition

{

public void Addition()

{

Scanner s = new Scanner(System.in); int a[][] = new int[3][]; int b[][] = new int[3][]; int c[][] = new int[3][]; for(int i=0;i<3;i++)

{

a[i] = new int[3]; b[i] = new int[3];

c[i] = new int[3];

}

System.out.println("Enter the elements of var size array a"); for(int i=0;i<3;i++)

{

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

{

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

}

}

System.out.println("Enter the elements of var size array b"); for(int i=0;i<3;i++)

{

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

{

b[i][j] = s.nextInt();

}

}

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

{

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

{

c[i][j] = a[i][j]+b[i][j];

}

}

System.out.println("The resultant matrix is: "); for(int i=0;i<3;i++)

{

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

{

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

}

System.out.println();

}

}

}

public class AdditionTest

{

public static void main(String args[])

{

Addition a = new Addition();

a.Addition();

}

}

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Can you give an example of array using character variable in c program?

the example of array over charcter variables is char ["string"]


What is the base address of an array in c program?

the address of variable (pointer) that contains array


You can use a variable to declare an array's size true or false?

True and false in the same time, because even so you can declare array size using notation for variables you have use constwhich makes your variable basically a constant:const int arraySize = 10;In Java, you can use any expression to define the array size, when you create the array. Once you create an Array object, however, you can't redimension it - but you can create a new Array object and destroy the old one.


Could you Write a program for 8086 microprocessor that displays on the monitor the average of 2 numbers from an array?

How to write a program for mouse in microprocessor?


How do you write a C Program to fill up an Integer Array?

Reference:cprogramming-bd.com/c_page1.aspx# array programming


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


Is an array is a collection of characters that can be fixed or variable?

No. An array is a collection of objects of any type, such as doubles, not just characters. You can even have arrays of arrays, or arrays of structs. In C, the size of an array is fixed, but it is possible to write code that will allow you to manually make it variable in size.


Is there a way to use a variable to declare the size of an array in true basic?

! variable to declase the size of an array in True Basic ! set up a dummy value for array - any initial value &gt; 0 is fine. DIM array$(999) ! ask the user for the length of the array INPUT PROMPT "Enter array size " :size ! resize the array with user defined length MAT REDIM array$(size) ! program end END


How do you initialize an array variable in java program?

An array in java is a collection of items stored into a single unit. The array has some number of slots (elements), each slot in the array can hold an object or a primitive value. Arrays in java are objects that can be treated just like other objects in the languageArrays can contain any type of element value , but we can't store different types in a single array. We can have an array of integers or an array of strings or an array of arrays.To create an array in java ,use three steps1. Declare a variable to hold the array2. Create a new array object and assign it to the array variable3. Store things in that array


What is array What is difference between array and simple variable?

An array stores several values - for example, several numbers - using a single variable name. The programmer can access the individual values with a subscript, for example, myArray[0], myArray[5]. The subscript can also be a variable, for example, myArray[i], making it easy to write a loop that processes all the elements of an array, or some of them, one after another.


What is the best way to write an array to a file in PHP?

The serialize() function is used to create a storable representation of a variable in PHP.To store an array to a file, you first use the serialize() function to change an array into a string. Save the string in a file using file I/O, so fwrite() or a similar function. When reading it use unserialize() to get the original array again.


How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.