Question: Create a C program as follows: 1. Ask the user for the name of a file, reading the name of the file from standard input.
Create a C program as follows:
1. Ask the user for the name of a file, reading the name of the file from standard input. The first two values in the file contains the number of rows and columns in a matrix. The remainder of the file is expected to contain the numbers in a matrix. Simple examples are provided below. For this project, no valid input file shall have more than 20 rows or 20 columns.
2. Read the contents of the file and determine if the matrix of numbers exhibits horizontal additive symmetry. The definition of this term is provided below.
3. If the matrix of numbers in the file exhibits horizontal additive symmetry, output horizontal additive symmetry to standard output. Otherwise, output no horizontal additive symmetry to standard output.
4. Print each row of the matrix, with the values of that row in descending order, one row per line of output. Format the output in an organized table using right-justified columns, as seen below. You must write your own function to sort the numbers.
5. Ask the user if they wish to process another file. If so, go back to step #1, above. Otherwise, terminate the program. Your program should use defensive programming techniques. This means your program should check input provided by the user for errors and deal with unexpected values without crashing. Ideally, the program should recover from any errors and continue processing.
Include detailed comments
Sample Run #1
3 2
56 12 98 25
34.5
45
Definition of horizontal additive symmetry:
A matrix of numbers is defined to exhibit horizontal additive symmetry if the sum of the numbers in the rows of the matrix exhibits horizontal symmetry. For this input file, the sums of the rows are:
68
123
79.5
Because this list is not symmetrical, this input file does not exhibit horizontal additive symmetry. (Remember, in a list with an odd number of values, the middle value is considered symmetric with itself.)
Here is the sample output of the program run with this input file:
Enter the filename: notsymmetric2.txt
no horizontal additive symmetry
56 12
98 25
45 34.5
Would you like to process another file? Enter Y or y to process another file: n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
