$25
Part 0. Write a program that performs following tasks respectively. These tasks should be distinct functions and called from main() function with selection. Once they been called, each will call another function to make the calculation for the related task. These calls will be made by selecting the inputs received from the user. For each process, the input / output part and the calculation part will be created separately. So you have to do the calculations in a separate function. This function should take the values required for calculation from the previous function as input and return output as a result. Also GCD and LCM calculation functions should write the results to text file.
PS: Don’t use any library other than stdio.h and math.h (math.h is only for use in Standard Deviation calculation formula).
Part 1. (15 pts) GCD Calculator: In this calculator, the greatest common divisor of two different numbers entered by the user should be calculated. After the selection is made, 2 integer numbers should be requested from the user, then these two numbers should be sent as input to the function named gcd_calculator(). It should return the calculation result as output. Finally, the calculated GCD value should be written to the
"result.txt" file.
Expected Output
Part 2. (15 pts) LCM Calculator: In this calculator, the least common multiple of two different numbers entered by the user should be calculated. You should follow the steps applied in GCD Calculator here as well. The only difference is that you should use the following formula when calculating LCM. After the selection is made, 2 integers should be requested from the user, then these two numbers should be sent as input to the function called lcm_calculator(). It should return the calculation result as output. Finally, the calculated LCM value should be written to the "result.txt" file.
Formula
𝑳𝑪𝑴(𝒙, 𝒚) ∗ 𝑮𝑪𝑫(𝒙, 𝒚) = 𝒙 ∗ 𝒚
Expected Output
Part 3. (25 pts) Standard Deviation Calculator: The standard deviation of this sequence should be calculated using the LCM and GCD values calculated in the previous stages in this calculator. You need to read these calculated values from the "results.txt" file. To calculate Standard Deviation, you should use the formula below. Here, you must first create a function named calculate_mean() to calculate the mean value. This function should calculate and return the average of the sequence contained in the "result.txt" file. Then, based on the formula below, you should calculate the standard deviation value in the standard_deviation_calculator() function.
Formula
𝒔𝒕𝒂𝒏𝒅𝒂𝒓𝒅𝑫𝒆𝒗𝒊𝒂𝒕𝒊𝒐𝒏 𝒎𝒆𝒂𝒏)𝟐
Expected Output
Part 3. (25 pts) File Operations: In file operations, you must create a function named write_file() for writing to the file. This function should take the value to be written to the file as a parameter. On the other hand, you do not need to write a function for reading values from the file. You have to perform this operation inside the functions that need it. In the "result.txt" file, your data should be as follows.
5 5 88 5 275 33 3542
Part 4. (20 pts) Create a makefile to compile and run the program by creating main.o and main.out files respectively. Your makefile should perform the following commands: clear (the terminal), clean (the files), compile and run.