Complex Numbers:
A high-school in Davis wants to have a program for theirstudents that can do basic operations on complex numbers.
A complex number is expressed by the form ,where and are real values and isthe imaginary number (). The common operations between complexnumbers are:
Addition:
Subtraction:
Multiplication:
Division:
Write program complex.c that reads an operation between twocomplex numbers and print the resulting complex number, asillustrated in the following example:
$ ./complex(3.5+5.2i)+(2.5-1.2i)=(6.00+4.00i)(3.5-5.2i)-(2.5+1.2i)=(1.00-6.40i)(3.5+5.2i)*(2.5-1.2i)=(14.99+8.80i)(3.5+5.2i)^(2.5-1.2i)Operation ‘^’ invalid(3.5+5.2i)/(2.5-1.2i)=(0.33+2.24i)totoInvalid input<Ctrl-D>$
Here are a list of requirements, assumptions and hints:
This program shall contain no global variables.
You should define a structure to represent complex numbers:struct complex_s.
You must implement the following functions:
int scan_complex_op(struct complex_s *c1, struct complex_s *c2,char *operator)
This function
PayPal Gateway not configured
PayPal Gateway not configured