Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

URGENT C PROGRAMMING The function ex can be approximated by the summation of an infinite series: x 2 x 3 x 4 e x =1+X+

URGENT C PROGRAMMING

The function ex can be approximated by the summation of an infinite series:

x2 x3 x4

ex =1+X++++

2! 3! 4!

  1. Write a recursive function double power (double x, int n) that returns the result of xn.

(5 marks)

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

Discuss the key ambient conditions and their effects on customers.

Answered: 1 week ago

Question

Be familiar with the integrative servicescape model.

Answered: 1 week ago

Question

Understand the role of corporate design in communications.

Answered: 1 week ago