Question: Please solve these problems. C++ CODE Two-dimensional Array Labs 10/15 1. Write a main program to read input from a file into a 5 (rows)x
Please solve these problems. C++ CODE
Two-dimensional Array Labs 10/15 1. Write a main program to read input from a file into a 5 (rows)x 7 (columns) array. Write a function rowSum, with parameters for the array and for a row index, which calculates and returns the sum of all the elements in the row designated by the row index parameter. Also have a printArray function which outputs the array in row-and-column form. The main program tests the functions. 2. Add a function columnMax which returns the maximum value in the elements of a designated column index. Also add code to the main program to test this function. 3. A square two-dimensional array is called a Magic Square when the sum of the values in every row, in every column, and in both diagonals is the same number (the magic number). Write a program that will check an n x n array, and report whether or not it is a magic squa Input: The array values, in row-major order, in an input file Processing: A function named checkMagic does the checking. Output: Output, to a file, shows (1) the array itself, as a table of values (2) A statement that it is or is not a Magic Square (3) If it is a Magic Square, the value of the magic number is shown. Note: The program will handle different values of n by using defined constants for the number of rows and columns. The value of n for a particular run goes in the blank. const int rows const int columns- int array[rows][columns]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
