eng
competition

Text Practice Mode

For C++ Programmer

created Jan 9th 2023, 14:48 by Veer Bharat Roy


0


Rating

484 words
27 completed
00:00
Q. C++ code to find the multiplication of two matrices using class and object approach  
 
#include <iostream>   
using namespace std;   
int main()   
{   
  int n, i, m=0, flag=0;   
  cout << "Enter the Number to check Prime: ";   
  cin >> n;   
  m=n/2;   
  for(i = 2; i <= m; i++)   
  {   
      if(n % i == 0)   
      {   
          cout<<"Number is not Prime."<<endl;   
          flag=1;   
          break;   
      }   
  }   
  if (flag==0)   
      cout << "Number is Prime."<<endl;   
  return 0;   
}
 
Input:  
Enter Matrix A
Enter x[0][0] : 1
Enter x[0][1] : 2
Enter x[1][0] : 3
Enter x[1][1] : 4
Enter Matrix B
Enter x[0][0] : 4
Enter x[0][1] : 3
Enter x[1][0] : 2
Enter x[1][1] : 1
 
Matrix A:
1 2  
3 4  
 
Matrix B:
4 3  
2 1  
 
Output:  
Addition of A and B matrix
8 5
20 13

saving score / loading statistics ...