====== HW 02 - Calculator ====== The task is to write a simple program that performs the following basic integer arithmetic operations: addition, subtraction, multiplication and division. You will get the operands from the standard input of your program as follows <1st operand> <2nd operand> The operands can also be negative numbers starting with //-// (minus sign). **The operands can also have more than 30 digits but less than 100 digits.** Thus, more than built-in types. Your program is expected to print the result of the desired arithmetic operation on the standard output, and the return value shall be //0//. However, there might be situations when an unsupported operation (meaning not one of the listed above) is entered. In such situations, the program prints //Error: wrong operator// and returns //2//. Also, any of the operands on the input might contain non-digit symbols, and those situations should result in printing //Error: wrong operands// and returning //3//. In any other erroneous situation, print //Error: unknown error// and return //1//. You can check your solution using Python, [[https://www.wolframalpha.com/|WolframAlpha]] or any other tool. No external library is allowed. fgets() function allows flexible reading of stdin getchar() reads a single character from stdin You can find other possibly useful functions in [[https://en.cppreference.com/w/c/io|stdio.h]] library Recall the variable-length array based on the user input from Lab02. You can find testing instances {{ :courses:be5b99cpl:hw:hw2_public.zip |here}} {{ :courses:be5b99cpl:hw:hw2_public_v2.1.zip |here **UPDATED 2022-10-18 12:30**}}. Files with the suffix ''.in'' contain your input with ''.out'' your desired output. When you have a file ''pub00.in'' containing the program input, you can pass it to your program in like $ cat pub00.in | ./main ===== Examples ===== ==== pub00 ==== ^ Standard input ^ Expected output ^ Return value ^ | 9 508983428 + 10 5303633367 | 5812616795 | 0 | ==== pub03 ==== ^ Standard input ^ Expected output ^ Return value ^ | 25 1109945105925303633367189 - 13 5303633367189 | 1109945105920000000000000 | 0 | ==== pub06 ==== ^ Standard input ^ Expected output ^ Return value ^ | 8 -53036333 * 55 -5089834282571709651070803999451059296045364409198455770 | 269946145925289289433504967492618198027807529912597563303491410 | 0 | ==== pub07 ==== ^ Standard input ^ Expected output ^ Return value ^ | 19 7170965107080399945 / 10 -4505913015 | -1591456623 | 0 | ==== Faulty instances ==== ^ Standard input ^ Expected output ^ Return value ^ | 5 71709 a 10 -4505913015 | Error: wrong operator | 2 | | 5 Hello - 10 -4505913015 | Error: wrong operands | 3 | | 5 71709 - 5 world | Error: wrong operands | 3 | ===== Evaluation ===== Upload your solution into [[https://cw.felk.cvut.cz/brute/|BRUTE]] as a zip archive containing only your program's source files. This program will have to be simply compilable or provided with a Makefile or detailed description of the compilation process. The maximum number of points is 10. No automatic evaluation, as you can test and verify your solution using the provided instances or generate your own. * 1 point - only small numbers * 3 points - addition and subtraction of large numbers * 3 points - multiplication of large numbers * 3 points - coding style (structured, commented, separated into functions etc.) ==== Bonus ==== * 5 points - division of large numbers (only integer operation and the remainder is omitted) ==== Late submission ==== * Submission is allowed one week after the deadline with the following penalties modifications: * 50% point reduction * It is not possible to use square brackets **arr[idx]** for array indexing. * There will be only positive integers * Bonus will be only for half points (5 -> 2.5 points) * deadline on Saturday **22. 10.** * max 7.5 points * deadline on Tuesday **25. 10.** * either max 5 points OR max 7.5 points without using square brackets **arr[idx]** for array indexing