|
|
|
#include <iostream> using namespace std; int main() { int n; cout << "Welcome to Matrix Multiply\n"; cout << "Enter size of Matrix:\n"; cin >> n; int A[n][n], B[n][n], C[n][n]; for(int i=0; i<n; i++) // taking user input of matrix A for(int j=0; j<n; j++) { cout << "Enter Value for Position A[" << i <<"][" << j <<"]" << endl; cin >> A[i][j]; } for(int i=0; i<n; i++) // taking user input of matrix B for(int j=0; j<n; j++) { cout << "Enter Value for Position B[" << i <<"][" << j <<"]" << endl; cin >> B[i][j]; } for (int m = 0; m < n; m++) // calculating the product of A and B for (int n1 = 0; n1 < n; n1++) { C[m][n1] = 0; for (int o = 0; o < n; o++) { C[m][n1] += A[m][o] * B[o][n1]; } } for(int i=0; i<n; i++) // printing output matrix C for(int j=0; j<n; j++) cout << "C[" << i <<"][" << j <<"]=" << C[i][j] << endl; } |
|
/*SAMPLE OUTPUT Welcome to Matrix Multiply Enter size of Matrix: 2 Enter Value for Position A[0][0] 1 Enter Value for Position A[0][1] 2 Enter Value for Position A[1][0] 3 Enter Value for Position A[1][1] 4 Enter Value for Position B[0][0] 5 Enter Value for Position B[0][1] 6 Enter Value for Position B[1][0] 7 Enter Value for Position B[1][1] 8 C[0][0]=19 C[0][1]=22 C[1][0]=43 C[1][1]=50 */ |
// Hit the thumbs up if you are satisfied with the answer. Happy Learning!
Develope a CPP program that multiplies two square matrixes. Your program will follow the steps below....
For the program described below, document your code well. Use descriptive identifier names. Use spaces and indentation to improve readability. Include a beginning comment block as well as explanatory comments throughout. In the beginning comment block, add your name, program name, date written, program description. The description briefly describes what the program does. Include a comment at the beginning of each method to describe what the method does. Write a program to perform operations on square matrices (i.e. equal number...
For the program described below, document your code well. Use descriptive identifier names. Use spaces and indentation to improve readability. Include a beginning comment block as well as explanatory comments throughout. In the beginning comment block, add your name, program name, date written, program description. The description briefly describes what the program does. Include a comment at the beginning of each method to describe what the method does. Write a program to perform operations on square matrices (i.e. equal number...
Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This will be the 3x3 matrix. Then, input 3, 64-bit, floating-point values. This will be a single-dimensional array and is the vector. Your program will simply ask the user to enter matrix values. Remember, there are 9 of these, but they need to be stored into a 3x3 multi-dimensional array (row-major). Then, your program will ask for the vector values, which will be stored into...
Write a program called problem4.cpp to implement an automatic teller machine (ATM) following the BankAccount class the we implemented in class. Your main program should initialize a list of accounts with the following values and store them in an array Account 101 → balance = 100, interest = 10% Account 201 → balance = 50, interest = 20% Account 108 → balance = 200, interest = 11% Account 302 → balance = 10, interest = 5% Account 204 → balance...
write a program that asks the user to enter two integers one at a time if the first value is not an integer then do not ask for a second then display both values otherwise print error message stating which value entered was not an integer python
You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...
I am having trouble figuring out why my program will not make any columns, just rows. I need to display a square. The instructions are provided below. (This for my C++ class) Write a program that displays a square. Ask the user for the square’s size. Only accept positive integer numbers (meaning choose a data type that holds positive integer values). The size the user gives you will determine the length and width of the square. The program should then...
Write a C program (not C++) that calls a function to multiply a matrix (two dimensional array). The main program should ask the user to enter an integer that will be used as the matrix “adder” and then call the function. The function should perform a matrix increment (every element of the array is incremented by the same value) and assign the result to another array. The function should be flexible enough to work with any array size and “adder”,...
follow the steps below to create a C program a) In the main function, fork a child process. b) In the child process, using an infinite loop to print out something. For example, you can print out the value of an int variable and each iteration increase the value of this int variable. You may also optionally sleep for a second or two in the loop to slow down the loop. c) In the parent process, sleep for a few...
Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...