answersLogoWhite

0

//Matrix multiplication import java.util.Scanner; public class Matrix

{

public static void main(String args[])

{

Scanner s= new Scanner(System.in);

int i,j,k; System.out.println("enter the value of n"); int n=s.nextInt(); int a[][]=new int[n][n]; int b[][]=new int[n][n]; int c[][]=new int[n][n]; System.out.println("enter the array elements of a:"); for(i=0;i<n;i++)

{

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

{

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

}

}//end of a matrix System.out.println("enter the array elements of b:"); for(i=0;i<n;i++)

{

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

{

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

}

}//end of b matrix System.out.println("the result matrix is:");

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

{

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

{

for(k=0;k<n;k++)

{ c[i][j]+=a[i][k]*b[k][j]; }

}

} for(i=0;i<n;i++)

{

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

{

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

}System.out.println();

}

}//end of main

}//end of class

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

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 algorithms of java programs?

Write a program that graphically demonstrates the shortest path algorithm


Is it possible to write a program in Java and partly in C?

Yes, that's what JNI is good for.


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.


How to write java program without using main method?

Java program without mainWe need a main method for executing a program.But YES we can write a program without using main() method.TRICK 1 of 2 :: while writing applets in java we don't use main... we use init() method instead.TRICK 2 of 2 :: using 'static' we can write a program whic will execute successfully and output the desired message on screen. Here it is :: class Mohit{ static { System.out.println("This java program has run without the main method"); System.exit(0); } } -->save the program as Mohit.java to compile::javac Mohit.java (in command prompt) to run ::java Mohit(command prompt) output will be ::This java program has run without the main methodWhoa!!!!! we are done.;)

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.


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'


How do you write java program to times a number?

Java, like many other programming languages, uses the asterisk for the multiplication operator. Therefore, two numbers a and b are multiplied, and their product assigned to a variable r, with this construct: r = a * b;


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


How To write a java program to create three tier applications using servlets?

barsanabegam