answersLogoWhite

0

import java.io.*;

import java.math.*;

public class addmatrices

{

public static void main(String args[])

{

int a[][]={{2,3},{4,5}};

int b[][]={{3,4},{5,2}};

int c[][]={{0,0},{0,0}};

int i,j;

System.out.println("matrix A:")

for(i=0;i<2;i++)

{

for(j=0;j<2;j++)

{

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

}

System.out.println();

}

System.out.println("matrix B:");

for(i=0;i<2;i++)

{

for(j=0;j<2;j++)

{

System.out.println(""+b[i][j]);

}

System.out.println();

}

System.out.println("Add Two Matrices");

for(i=0;i<2;i++)

{

for(j=0;j<2;j++)

{

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

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

}

System.out.println();

}

}

}

User Avatar

Wiki User

∙ 15y ago

What else can I help you with?

Related Questions

How do you develop a JAVA program that computes matrices?

Matrices can't be "computed" as such; only operations like multiplication, transpose, addition, subtraction, etc., can be done. What can be computed are determinants. If you want to write a program that does operations such as these on matrices, I suggest using a two-dimensional array to store the values in the matrices, and use for-loops to iterate through the values.


How do you write a java program to find the square root of a number?

You can use the Math.sqrt() method.


Can we add website link when we write java program?

yes ,i can add the website link in java program when we write.


Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


What is javadoc?

write a java program to display "Welcome Java" and list its execution steps.


How write new line program in java?

\n


How do you write a java program for finding multiligual languages?

You can use Java's built-in functions to write a code that will find multilingual languages.


How java is 100 percent Internet based?

It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.


Write a java code to draw a circle inside in an ellipse?

write a program draw circle and ellipse by using oval methods in java


How do you write a java program to find the ad joint of a matrix?

bgfygfrhjyuyhh


How do you write algorithms of java programs?

Write a program that graphically demonstrates the shortest path algorithm


Can you write java program in Microsoft Word?

Since the Java program is basically a text file, you can write it in any text editor (although using a Java IDE, or an IDE with support for Java, does give you certain advantages). Thus, you can use programs such as NotePad or NotePad++ to write the Java program. Using word processors such as MS-Word is problematic, because these insert additional codes. You would have to make sure you save the resulting file in the text format - give the "Save As" command, and choose a text format from the list.