Question
URGENTT C PROGRMMING IN 1 HOR PLSS The function ex can be approximated by the summation of an infinite series: x 2 x 3 x
URGENTT C PROGRMMING IN 1 HOR PLSS
The function ex can be approximated by the summation of an infinite series:
x2 x3 x4
ex =1+X++++
2! 3! 4!
- Write a recursive function double power (double x, int n) that returns the result of xn.
- You are required to write the main function of the C program that can be used to evaluate ex using the infinite series. The program will terminate when the difference between the answer after n terms and the answer after n-1 terms s less than 10-4. The program will take one command line argument: x that is the value of the parameter in ex. For example, if the user wants to determine e15, the following command can be invoked:
e.exe 1.5
The program will then evaluate the expression and display the result to standard output as shown below:
e^1.5000 = 4.4817
The program will also print an appropriate error message to standard error if the user does not provide the correct number of arguments to the program.
The program will call two functions: double fact (int n) that returns the factorial value of an integer as a double and double power (double x, int n) as written in part (a). Note that you do need to write the factorial function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started