Question: In this lab exercise, you are required to write a C++ program to add two 4 * 5 matrices and then output the results to

 In this lab exercise, you are required to write a C++
program to add two 4 * 5 matrices and then output the
results to the screen. Prompt the user to enter the name of
two files with matrices Compute the sum of the two matrices and

In this lab exercise, you are required to write a C++ program to add two 4 * 5 matrices and then output the results to the screen. Prompt the user to enter the name of two files with matrices Compute the sum of the two matrices and output the results A sample run is as follows: Please enter the name of the file containing data for Array 1: input1.txt Please enter the name of the file containing data for Array 2: input2.txt The sum is: 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 5 6 7 8 9 . Further requirements: o Create three functions: . readArray with void return and one 2D array argument and one string argument printArray with void return and one 2D array argument sumArray with void return and three 2D array arguments - Separate your code into three files as described in the lab: main.cpp . myFunction.cpp my Function.h Remember, you will have to break the compiling into three steps now: a g++ -c main.cpp b. g++ -c myFunction.cpp c. g++ main.o myFunction.o -o main . The two input files are available by clicking: input1.txt and input2.txt myfunct.h #ifndef MYFUNCT_H #define MYFUNCT_H //all constants H/all typedef's I/all function prototypes #endif main.cpp #include "myfunct.h" int main() 10 //body of main myfunct.cpp #include "myfunct.h" /function bodies g++ -c main.cpp g++ -c myfunct.cpp main.o myfunct.o g++ main.o myfunct.o -o main main 10 #include 11 #include 12 using namespace std; 13 14 const unsigned int R_SIZE = 4; 15 const unsigned int C_SIZE = 5; 16 void readArray( int twoDArray[] [], string inputFileString); // function prototype 18 int main() 20 - { 21 int i, j; 22 int array1 [C_SIZE] [R_SIZE); 23 string fileName; 24 25 // prompt user for input 26 cout > fileName; 19 28 29 30 31 - 32 33 - 34 35 36 37 38 39 readArray(array1[] [] , fileName); for (i = 0; i > array[i][j]; 61 } 62 } 63 64 inf.close(); 65 } // end readArray function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!