Homework 4 Time it took Matthew to Complete: 10 mins
• All programs must compile without warnings when using the -Wall and -Werror options
• Submit only the files requested
◦ Do NOT submit folders or compressed files such as .zip, .rar, .tar, .targz, etc
• Your program must match the output exactly to receive credit.
◦ Make sure that all prompts and output match mine exactly.
◦ Easiest way to do this is to copy and paste them
• All input will be valid unless stated otherwise
• Print all real numbers to two decimal places unless otherwise stated
• The examples provided in the prompts do not represent all possible input you can receive.
• All inputs in the examples in the prompt are underlined
◦ You don’t have to make anything underlined it is just there to help you differentiate between what you are supposed to print and what is being given to your program
• If you have questions please post them on Piazza
Restrictions
• No global variables are allowed
• Your main function may only declare variables, call other functions, and assign
variables values.
Files to submit: mat_add.c
Write a program called mat_add.c that asks the user for 2 matrices A, and B, and displays their sum, C.
1. All numbers entered will be integers
2. All matrices will be valid
3. The maximum dimension of each matrix is 100
4. Each row of the matrix will be entered 1 line at a time
5. The formula for calculating C[i][j] is C[i][ j]=A[i][ j]+B[i][ j]
1. For more on how to compute the sum of two matrices see here:
http://www.purplemath.com/modules/mtrxadd.htm
6. Examples:
1. Please enter the number of rows: 2
Please enter the number of columns: 2 Enter Matrix A
12
34
Enter Matrix B 100 200
200 400
A+ B =
101 202
203 404
2. Please enter the number of rows: 2
Please enter the number of columns: 3 Enter Matrix A
10 20 -30
12 7
Enter Matrix B 1 2 30
-3 4 5
A+ B =
11 22 0 -2 6 12