Jump to content

Sunila Jha

Members
  • Posts

    3
  • Joined

  • Last visited

Sunila Jha's Achievements

Lepton

Lepton (1/13)

0

Reputation

  1. You can use for-loop to implement Matrix Multiplication in Java import java.util.Scanner; public class MatrixMultiplicationExample{ public static void main(String args[]){ int row1, col1, row2, col2; Scanner s = new Scanner(System.in); System.out.print("Enter number of rows in first matrix:"); row1 = s.nextInt(); System.out.print("Enter number of columns in first matrix:"); col1 = s.nextInt(); System.out.print("Enter number of rows in second matrix:"); row2 = s.nextInt(); System.out.print("Enter number of columns in second matrix:"); col2 = s.nextInt(); if (col1 != row2) { System.out.println("Matrix multiplication is not possible"); } else { int a[][] = new int[row1][col1]; int b[][] = new int[row2][col2]; int c[][] = new int[row1][col2]; System.out.println("Enter values for matrix A : \n"); for (int i = 0; i < row1; i++) { for (int j = 0; j < col1; j++) a[i][j] = s.nextInt(); } System.out.println("Enter values for matrix B : \n"); for (int i = 0; i < row2; i++) { for (int j = 0; j < col2; j++) b[i][j] = s.nextInt(); } System.out.println("Matrix multiplication is : \n"); for(int i = 0; i < row1; i++) { for(int j = 0; j < col2; j++){ c[i][j]=0; for(int k = 0; k < col1; k++){ c[i][j] += a[i][k] * b[k][j]; } System.out.print(c[i][j] + " "); } System.out.println(); } } } } To know more about the Matrix Multiplication read more on commercial url removed by moderator.
  2. Hi All, I wanted to do a Data Science Course but, i don't have any prior knowledge in programming. One of my friend told me to learn Java and Python (i have started learning python on Scaler Topics). My questions is, is there any other programming language i should learn?
  3. Hi @zak100, I am not sure if you still need help in this or not but if you still does, check this article once - https://www.scaler.com/topics/find-function-in-python/ Hope this will help you some way.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.