Question: Examples of input and output: Write a program in C that: Asks the user to enter a real number x that is between-1and1(both included). If

 Examples of input and output: Write a program in C that:

Examples of input and output:

Asks the user to enter a real number x that is between-1and1(both

Write a program in C that: Asks the user to enter a real number x that is between-1and1(both included). If the user enters a number that does not satisfy this condition, the program prompts the user again, until a number x s.t. -1 0 is entered The program then computes an approximation y to the exponential ex by summing up, on y, which is initialized to 0 the different terms of the sum The program uses a loop on I from 0 to n (both included) to do so. In the loop, the values (i = and pi = rare maintained. Observe that: - As i moves from 2 to 3 for example, the value c; moves from c = 1 to 03 = 1:23. This means c3 = $. - As i moves from 2 to 3 for example, the value pi moves from p2 = r2 to 23 = 23 = 22. 1. This means P3 = P2.2. - The values and p; are all real numbers, so they must be maintained on double variables. After the loop, the program displays the approximation to ex it computed, as well as the math library's result obtained with a call to exp(x). Caution: your program must not use any other function out of the math library, such as pow(x,y). Please enter a real number between -1.0 and 1.0: 0.0 Please enter a non-negative integer number: 17 Our approximation of exp(0.000000) 1.000000. The math library says: exp(0.000000) = 1.000000. Please enter a real number between -1.0 and 1.0: 1.0 Please enter a non-negative integer number: 17 Our approximation of exp (1.000000) 2.718282. The math library says: exp (1.000000) = 2.718282. Please enter a real number between -1.0 and 1.0: 0.69 Please enter a non-negative integer number: 17 Our approximation of exp(0.690000) 1.993716. The math library says: exp(0.690000) = 1.993716. Please enter a real number between -1.0 and 1.0: 2 Sorry. Your input, 2.000000, is out of bounds. Try again. Please enter a real number between -1.0 and 1.0: -1 Please enter a non-negative integer number: -1 Sorry. Your input, -1, is incorrect. Try again. Please enter a non-negative integer number: 17 Our approximation of exp(-1.000000) 0.367879. The math library says: exp(-1.000000) 0.367879

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!