The program shown in Appendix B implements a very simple spread sheet based on an array of real numbers. There are two procedures that need to be completed. They are SumARow and Compute. The rest of the program will read in an array of numbers and do some computation on the elements (values) in the array using those procedures.
Copy the file ``/usr/copy/aps105/spread.t'' into your working directory and rename it ``part2.t''. A listing of this file is given in Appendix B on page .
Complete the two procedures SumARow and Compute according to the specifications given in the More Information section below.
No checking is done. For the existing main program, an array with 4 rows and 5 columns will work without error.
You should only write the code for the procedures. Do not change any other part of the program when you submit your solution, though you are free to make modifications while testing. Just make sure that the program you submit has the original code.
For the procedure SumARow, the order of the parameters is RowNumber, StartCol, EndCol, DestCol, and the 2-dimensional array. The procedure does the following: In row RowNumber, sum the values in the columns from StartCol to EndCol and put the result in DestCol.
For the procedure Compute, the order of the parameters is Row1, Row2, Row3, RowR, StartCol, EndCol, and the 2-dimensional array. The procedure does the following: For each column from StartCol to EndCol, inclusive, compute the function A(RowR) := A(Row1) + A(Row2) * A(Row3)
where A(x) represents the element in column x of the row.
An example of the input sequence is:
Number of rows? 4 Number of columns? 5 Input the elements by rows Row 1: 1 2 3 4 5 Row 2: 6 7 8 9 10 Row 3: 11 12 13 14 15 Row 4: 16 17 18 19 20
Go here to see a solution.