Question: please typset code so it can be copied and pasted . thanks soo much and please include comments Exercise 1 (Complex Calculator) Implement a calculator

please typset code so it can be copied and pasted . thanks soo much and please include comments
please typset code so it can be copied and pasted . thanks
soo much and please include comments Exercise 1 (Complex Calculator) Implement a

Exercise 1 (Complex Calculator) Implement a calculator for complex numbers. The program must read the arguments and operators from the command line. Examples: The call complexcalc.exe (1,1) * (2,1) will produce the output (1,1) * (2,1) = (1,3) The user must provide the complex numbers in the () notation with parentheses. 1.e. (x,y) without any spaces! In between the complex numbers there must be the operator (+-*/) but with spaces between the numbers (a) Use a struct named complex for representing the complex number with the fields real and imag. The calculator shall support the operations + - * / at least (b) Handle all possible errors appropriately, especially wrong input. All errors must go to STDERR (using fprintf). (c) Extend your program to support the power operator, i.e.. complexcalc.exe (3,4) ** 2 shall square the complex number. Attention: On the command line you must give two signs like that (**), but the program only receives one of that (-). Output e.g. (3,4) - 2 = (-7,24) (d) Extend the program so that it supports more than one operation. Do this by asking N (1,1) (2,1) * (0,1) + (1,0) (2,0) (0,1) (-1,0) + + + (e) For this RPN operation it is useful to have a stack of operands, so please implement a stack that can hold 10 or more operands (e.g. by using an array of struct complex plus a stack pointer/index). Example: #define MAX_STACK_DEPTH 10 typedef struct complex item [MAX_STACK_DEPTH] : int stack index; } complex stack; (f) Try and test this computation by a lot of examples, at least 10 different calculations. You may specify these 10 test cases by hard codes test arrays instead of taking from the command line. Example: char testcases [5] [6] [12] = { {"(1,2)","(2,3)","+"), {"(1,2)","(2,3)","-"), {"(0,1)","(0,1)","*"}, {"(1,0)","(8,9)","/"), {"(0,2)","4",""), }; for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!