Question: Question: Write a C program which makes the necessary calculations according to the given formulas below. Formulas: C(n,r) n! r!(n-r)! n! P(n,r) = (n-r)! Create

Question: Write a C program which makes the necessary calculations according to the given formulas below. Formulas: C(n,r) n! r!(n-r)! n! P(n,r) = (n-r)! Create 3 functions with these names: Fact(), Calculate_CO, Calculate_PO). Fact function, should receive the value that you want to calculate its factorial and return the result to the main Calculate_C function, should receive the result of factorial values presented on the formula above, calculate the result (float) and return it to the main Calculate_P function, should receive the result of factorial values presented on the formula above, calculate the result (float) and return it to the main The main function should input the N and R values from user, call the Fact function for calculating the factorial of each N and R values then call the Calculate C and Calculate_P functions with the factorial values returned by the Fact function. Main should also display the results returned from Calculate C and Calculate P functions as shown in the sample run. Your main program should stop when the user has entered a negative value for Nor R. Also N value should be greater than R value to calculate and display the results. Please review the sample run and make sure your program works the same way. Sample Run 1: Enter N value: 6 Enter R value: 4 C value : C(6,4) - 15.00 P value : P16,4) - 360.00 Enter N value: 8 Enter R value: 2 c value : C(8,2) - 28.00 P value : P(8.2) - 56.00 Enter N value: 3 Enter R value: 5 value should be greater than R value ! Try again. Enter N value: 7 Enter R value: -2 Error : Nor R value should be equal or greater than zero. Bye! Process exited after 13.82 seconds with return value e Press any key to continue Sample Run 2: Enter N value: 5 Enter R value: 4 C value : C(5,4) = 5.00 P value : P(5.4) - 120.ee Enter N value: 3 Enter R value: 8 * value should be greater than R value ! Try again. Enter N value: -4 Enter R value: 6 value should be greater than R value ! Try again. Error : Nor R value should be equal or greater than zero. Bye! Process exited after 20.06 seconds with return value o Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
