
Need help with this program which needs to be done in C++
using namespace std;
int main()
{
int i,j,a,b, first[3][3], second[3][3], sum[3][3], subtract[3][3],
multiply[3][3],scalar,scalarf[3][3],scalars[3][3];
a=b=3;
cout<<"\nEnter the scalar miltiplier:";
cin>>scalar;
cout << "\nEnter the elements of first matrix : ";
for (i=0;i<a;i++ )
{
for (j=0;j<b;j++ )
{
cin >> first[i][j];
}
}
cout << "\nEnter the elements of second matrix:";
for (i= 0 ;i< a ;i++ )
{
for (j= 0;j<b;j++ )
{
cin >> second[i][j];
}
}
for (i=0;i< a;i++ )
{
for (j=0;j<b;j++ )
{
sum[i][j] = first[i][j] + second[i][j];
subtract[i][j] = first[i][j] - second[i][j];
scalarf[i][j]=first[i][j]*scalar;
scalars[i][j]=second[i][j]*scalar;
}
}
for(i = 0; i < a; ++i)
for(j = 0; j < b; ++j)
{
multiply[i][j]=0;
}
// Multiplying matrix a and b and storing in array mult.
for(i = 0; i < a; ++i)
for(j = 0; j < b; ++j)
for(int k = 0; k < a; ++k)
{
multiply[i][j] += first[i][k] * second[k][j];
}
cout << "\nFirst matrix : "<<endl;
for (i=0 ; i < a ; i++ )
{
for ( j = 0 ; j < b ; j++ )
{
cout << first[i][j] << "\t";
}
cout << endl;
}cout << "\nSecond matrix : "<<endl;
for (i=0 ; i < a ; i++ )
{
for ( j = 0 ; j < b ; j++ )
{
cout << second[i][j] << "\t";
}
cout << endl;
}
cout << "\nSum of entered matrices : "<<endl;
for (i=0 ; i < a ; i++ )
{
for ( j = 0 ; j < b ; j++ )
{
cout << sum[i][j] << "\t";
}
cout << endl;
}
cout << "\nSubtraction of entered matrices :
"<<endl;
for (i=0 ; i < a ; i++ )
{
for ( j = 0 ; j < b ; j++ )
{
cout << subtract[i][j] << "\t";
}
cout << endl;
}
cout << "\nMultiplication of entered matrices :
"<<endl;
for (i=0 ; i <a ; i++ )
{
for ( j = 0 ; j < b ; j++ )
{
cout << multiply[i][j] << "\t";
}
cout << endl;
}
cout << "\nScalar multiplication of first matrix :
"<<endl;
for (i=0 ; i <a ; i++ )
{
for ( j = 0 ; j < b ; j++ )
{
cout << scalarf[i][j] << "\t";
}
cout << endl;
}
cout << "\nScalar multiplication of second matrix :
"<<endl;
for (i=0 ; i <a ; i++ )
{
for ( j = 0 ; j < b ; j++ )
{
cout << scalars[i][j] << "\t";
}
cout << endl;
}
return 0;
}
![A matrixfunction.cpp 1 using namespace std; 2 int main() 3 { 4 int i,j,a,b, first[3] [3], second [3][3], sum[3][3], subtract[](http://img.homeworklib.com/questions/641b3a60-f140-11eb-8986-174794ba294f.png?x-oss-process=image/resize,w_560)
![A 34 Tur matrixfunction.cpp - U; T a; FFT) for(j = 0; j < b; ++i) multiply[i][j]=0; // Multiplying matrix a and b and storing](http://img.homeworklib.com/questions/64cb4ee0-f140-11eb-8c65-3ff2b6f879f5.png?x-oss-process=image/resize,w_560)




Please upvote... Thanks
Need help with this program which needs to be done in C++ 2 dim arrays as...
3. Write a complete assembly language program to read two matrices (2-dim arrays) A and B and display the resulting matrix C, which is the sum of A and B. Procedures must be used to organize the code.
use Python IDEL
Problem 4 Fix a program. This program should calculate the matrix addition (C - A+B, where each element of matrix C is equal to the sum of the elements of matrices A and B that have the same indexes cij - aij + bij). However it is incomplete: the range() function arguments, index values of nested lists A, B, and C, and two list statements are missing. Can you find them and fix the program? What is...
Need help!!
1) Let A, B, C, and D be the matrices defined below. Compute the matrix expressions when they are defined; if an expression is undefined, explain why. [2 0-1] [7 -5 A= .B -5 -4 1 C- ,D= (-5 3] [I -3 a) AB b) CD c) DB d) 3C-D e) A+ 2B 2) Let A and B be the matrices defined below. 4 -2 3) A=-3 0, B= 3 5 a) Compute AB using the definition of...
Use
c++ as programming language. The file needs to be created ourselves
(ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...
I need the real code for this program: (convert pseudocode to C++) ——————————————————— Start Program Type Vector is Structure Defined x is double variable y is double variable End Vector Type Function Prototype Get Choice(parameters: int &) Function Prototype vAddition (parameters: vector v1, vector v2, vector &v3) Function Prototype vSubstract(parameters: vector v1, vector v2, vector &v3) Function Prototype sMult(parameters: int k, vector v, vector &v3) Function Prototype sProduct (parameters: vector v1, vector v2) Function Prototype getMag (parameter: vector v) Function...
The assignment In this assignment you will take the Matrix addition and subtraction code and modify it to utilize the following 1. Looping user input with menus in an AskUserinput function a. User decides which operation to use (add, subtract) on MatrixA and MatrixB b. User decides what scalar to multiply MatrixC by c. User can complete more than one operation or cancel. Please select the matrix operation 1- Matrix Addition A+ B 2-Matrix Subtraction A-B 3Scalar Multiplication sC 4-Cancel...
You are wanting to communicate secret messages with your friend, and you choose to do this with matrices. The encoding matrix that you choose to use is 2 -2 -1 6 You use the following key to convert your message into a string of numbers, where "O" is used as a placeholder where required. A B C D EF G H IJ K L M 10 2 11 24 19 5 25 20 3 7 16 6 14 N O...
discrete math question 2
i meant question 4
Boolean Algebra and Computer MAT335 T 632 Be 56 matrix addition and 4. Let Ah(Z) denote the set of 2 × 2 matrices with integer entries, and let + denote denote matrix multiplication. Given then A'- Using[0 이andld :] 「0 0 lo 0 as the 0 element and the 1 element, respectively, either prove [(Z,+,, ', 0, 1 is a Boolean algebra or give a reason why it is not. s and...
68 4 64 73 1 5. Matrix C is a coded message where C61 4 52 51 0 109 5 120 170 5 You know that each letter of the original message was first replaced with the number corresponding to its placement in the English alphabet (eg. E was replaced with 5) and any spaces in the message were replaced with zeroes. Then the message was encoded by multiplying the message matrix, M, on the left by the coding matrix,...
I already solved part A and I just need help with part B
1. Matrix Multiplication The product of two n xn matrices X and Y is a third n x n matrix 2 = XY, with entries 2 - 21; = xixYk x k=1 There are n’ entries to compute, each one at a cost of O(n). The formula implies an algorithm with O(nº) running time. For a long time this was widely believed to be the best running...