Files to submit: complex_mult.c
Time it took Matthew to complete: 5 minutes
- 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
- 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
In this program you will multiply two complex numbers together. A complex number has the form
a is the imaginary part
b is the real part
i represents √−1
Write a program that accepts two complex numbers, multiplies them together and then displays the result.
Notes: There may be any number of spaces between the numbers, i, and the plus sign and your program should be able to handle that.
Hint: Don’t forget that i∗i=√−1∗√−1=−1 .
- Enter the first complex number in the form ai + b: 5i + 3 Enter the second complex number in the form ai + b: 2i + 4 (5i + 3) * (2i + 4) = 26i + 2
- Enter the first complex number in the form ai + b: 10 i + 3 Enter the second complex number in the form ai + b: 6i+1 (10i + 3) * (6i + 1) = 28i + -57
- Enter the first complex number in the form ai + b: 1i+2
Enter the second complex number in the form ai + b: 3 i + 4 (1i + 2) * (3i + 4) = 10i + 5
Time it Took Matthew
About 40 minutes but I forgot to time myself this time 🙁
What to submit
A zip file containing
- A CMakeLists.txt to compile your submission
- All of your source files for your answer (.c and .h files)
Make sure to not accidentally zip the folder that contains your answer but instead the files themselves.
Don’t Zip This
Write a program to find the determinant of a matrix. For how to find a determinant of a matrix please see: https://www.mathsisfun.com/algebra/matrix-determinant.html. Here you can find a determinant calculator to help you check your work: https://www.symbolab.com/solver/matrix-determinant-calculator
1. The name of the file containing the matrix will be given on the command line a. This name will always be valid
- The structure of a matrix file is Num_rows num_cols
row1_val1 row1_val2 row1_val3… row2_val1 row2_val2 row2_val3… …
- The files will always be structured correctly
- The matrices will always be square, ie N X N
- The values in the matrix are real numbers
- You should always print your answer to 2 decimal places
- You must use a struct to represent your matrix object
a. If you do not use a struct the TAs will manually deduct 50% from your score after the due date has passed
- Your solution should consist of at least 3 source files a. matrix.c
- In order to ensure that your CMakeLists.txt generates the correctly named executable,
add the following bit of code to the end of your CMakeLists.txt
a. set_target_properties(exeName PROPERTIES
b. Where exeName is the first argument to add_executable
i. So if you had add_executable(problem3 …) then you should
replace exeName with problem3
c. I’ve included an example CMakeLists.txt for that has this edit done on it already
- This problem is recursive
- Make sure to only open the file in read (“r”) mode. If you open it in read and write (“r+”)
mode or write (“w”) mode you will get an error as you only have read permissions for the
- You are free to write as many functions as you want, so take advantage of that fact and
break the problem down into lots of steps
In the following example, input has been underlined to help you tell it apart from what you should output. You don’t need to underline anything, it is just a visual aid for you.
Assume the file 3X3Matrix.txt had the following contents 33
./findDeterminant.out 3X3Matrix.txt The determinant is 0.00.