Starting from:
$30

$24

Homework 1 SOlution

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

ai+b

where

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 .







Examples:

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



More products