Write a Program for matrix multiplication.



Write a Program for matrix multiplication...

Answer / Sandeep Gupta

"Here is a simple Python code for multiplying two matrices. In this example, I am using nested loops and assuming the matrices are square.nn```pythonnn = int(input("Enter the number of rows (and columns) for both matrices: "))na = [[0]*n for _ in range(n)]nb = [[0]*n for _ in range(n)]nc = [[0]*n for _ in range(n)]nprint("Enter elements of matrix A:")nfor i in range(n):n for j in range(n):n a[i][j] = float(input())nprint("Enter elements of matrix B:")nfor i in range(n):n for j in range(n):n b[i][j] = float(input())nfor i in range(n):n for j in range(n):n for k in range(n):nc[i][j] += a[i][k]*b[k][j]nprint("The resultant matrix C is:")nfor i in range(n):n print(*c[i])"n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Code AllOther Interview Questions

Devise a program to implement the Fibonacci sequence.

1 Answers   Tech Mahindra,


How to find the list of users who have two codes su01 and pfcg? thank in advance all.

1 Answers  


Write a Program to find the reverse of a given number.

1 Answers   InterGraph,


Write a Program to find the number of words in a sentence.

1 Answers   InterGraph,


Write a sql query to find n'th maximum in the database table.

3 Answers   Oracle,


You have been asked to install a servlet engine (tomcat, glassfish, etc.) for a companies servlets. Assuming the company has an existing web/DBMS server (which may or may not be on the same server), explain in detail how would you implement the development project and a deployment solution.

1 Answers  


1.What happens to a session object when the browser associated with it is closed? 2. Explain what happens when a servlet is sent a POST request? 3. Why does only one copy of a servlet get created? 4. Explain what happens when a browser requests a servlet? (for the first time) 5.How is information stored in a session object?

1 Answers  


Write a program to Print the Pascal triangle

1 Answers   InterGraph,


Write a Program to find the sum of digits of a given number until the sum becomes a single digit.

1 Answers   InterGraph,


import java.awt.*; import java.awt.event.*; public class Agency extends Frame implements ActionListener { Label l1,l2,l3,l4; Button b1; TextField t1,t2; String s1,s2,s3,s4; public static void main(String args[]) { new Agency().setVisible(true); } public Agency() { super("Gas Agency Package"); setSize(1280,800); setBackground(Color.lightGray); setLayout(null); // setLayout(new BorderLayout()); t1=new TextField(20); t1.setBounds(440,150,200,30); t1.setBackground(Color.white); t2=new TextField(20); t2.setBounds(440,180,200,30); t2.setBackground(Color.white); t2.setEchoChar('*'); l1=new Label("Gas Agency Package"); l1.setBounds(400,30,300,50); l1.setFont(new Font("TimesRoman",Font.BOLD,25)); l1.setAlignment(Label.CENTER); l2=new Label("Enter your ID and Passoword"); l2.setFont(new Font("TimesRoman",Font.BOLD,20)); l2.setBounds(270,80,300,50); l3=new Label("Enter ID"); l2.setFont(new Font ("TimesRoman",Font.BOLD,20)); l3.setBounds(270,150,120,50); l4=new Label("Enter Passoword"); l2.setFont(new Font ("TimesRoman",Font.BOLD,20)); l4.setBounds(270,180,140,50); add(l1); add(l2); add(l3); add(t1); add(l4); add(t2); b1=new Button("Login"); b1.setBackground(Color.white); b1.setBounds(400,280,100,70); b1.addActionListener(this); add(b1); } public void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { s3="svce"; s4="svce"; s1=t1.getText(); s2=t2.getText(); if(s1.equals(s3) && s2.equals(s4)) { //System.out.println("password is correct"); MenuForm m= new MenuForm(); m.setVisible(true); //this.dispose(); } else { System.out.println("password not correct"); } this.dispose(); } } } plzzzzzzz xplain me this java code like why i m including this packages n the whole code plzzzzzz

1 Answers  


Main frame : I have a PS file. 4 records. I need toread a particular field of that file and then add it up. then write the added field along with all other fields

1 Answers  


can any body give me answer to this question please? please give me code in cl with the folling specifications. 1.Accept 2 parameters-date and date type 2.If date type is J then convert date to *MDY format 3.If date type is M convert date to *JUL format 4. Send a program message with the value of converted date? Please give me the answer.Because im practicing in my house.Im taking trining on AS/400.

1 Answers  


Categories