- The user will be asked for a base name (a string) from which the input and output filenames will be constructed by adding .in and .out.
For example, if the user enters
numbers
,
the input file will be numbers.in
and the output file will be numbers.out
.
- The program will read in two matrices (2D arrays) of floats from
the input file.
The input file will be formatted as follows. The first line will contain the number of rows, then the number of columns,
separated by a space. The next set of lines will contain the numbers of the first matrix.
Each row's numbers will appear on one line, separated by spaces.
A single blank line will separate the two matrices. The next set of lines will contain the numbers of the second matrix in the same form.
For example, the following matrices:
and
are indicated by the file small.in
in the Eclipse project.
- The program will create a new matrix to hold the sum of the two matrices read in, and fill it with the sum of those matrices.
Recall that the sum of two matrices is just computed element-by-element.
For example, the sum of the two matrices above is
- The program will write out the resulting matrix to the output
file.
The columns must line up nicely, with results displayed to the
thousandth place. When choosing the total width, you may
assume that the results will be no larger than 99.9.
To do this project, do the TODO's in the project file. But note:
- Grading:
- 3 points for the description at the top of the file, of what the project does.
- 3 points for getting the basename from the user and constructing the input and output file names from the basename.
- Hint: Using
strcpy
followed by strcat
makes it easy to construct
the input and output filenames from the basename.
- Hint: Using
fscanf
for reading from the input files is the easiest approach for this project.
- 7 points for reading the two matrices successfully.
- Hint: Using
fscanf
for reading from the input files is the easiest approach for this project.
- 7 points for summing the two matrices successfully.
- 10 points for printing the sum successfully.
- Note the Hints above. .
- As usual, commit your work to turn it in.
-
Begin working on your final C project,
AroundTheWorld, to be
completed by Saturday no later than 11:59 PM.
- You may do this either by yourself or with a partner — your choice. If you choose to work with a partner:
- Write BOTH names at the top of your source code files.
- Email your instructor the two names of your partnership.
- You have already learned everything you need to do this project. We suggest that you proceed at least
as quickly as in the following schedule:
- In class Monday: ask your instructor to demo the project and explain it.
- Monday night: read the project instructions (per the above link) and bring questions to class Tuesday.
- Monday night: Sketch the organization of your project -- what functions will you need to write? What structures?
Consider drawing a structure diagram.
- Tuesday: Examine the TestScores project that we gave you.
- You don't need to understand all of it at this point, but you DO need to know WHAT IT COULD HELP YOU WITH.
- Throughout the project, refer to the TestScores project as needed for details on how to do some of the steps.
- Tuesday and Wednesday: Begin implementing.
- Thursday: Bring your questions to class.
- Thursday through Saturday: Finish implementing.