Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment you will write a C program to show a menu to the user to select the function to evaluate. The menu will

In this assignment you will write a C program to show a menu to the user to select the function to evaluate.

The menu will look like:

Please select an option:

a) Evaluate exponential function

b) Evaluate sin function

c) Exit The only options valid are from a to c.

image text in transcribed Any other option should display a message warning the user, and asking to try again. The program will finish only when option c is chosen. If a or b is chosen, the program will ask the user to enter a value for x, and number of terms (t); after the values are entered, the program will call a function to evaluate the corresponding series, and display the result of comparing the value obtained using the series to the value using the corresponding function (exp or sin) in math.h, and the percent error(difference between your calculation and the value from the math.h function), immediately after (press any key to continue), the program will display the menu again.

Background: The exp and sin ofx, can be obtained using power series 2 4 n=0 (-1)%2n+1 sin(x) 3! 5! n=0 Vexp - Vmathh 100 math.h Example: Since time is limited, we won't evaluate the series all the way to GO; instead we will ask the user for a number of terms to be considered, say t. For example if the user chose to evaluate the exponential function for x-0.5, and t-4: 0.53 0.54 exp(0.5)-eo s = 0S" = + 0.5 + 0212 + T + T = 1.648 n=0 Now, using the exp function in math.h: exp(0.5) -1.648721 We now calculate the %error using the formula: Vexp Vmath.h +100 math.h Where Vexp is the value obtained using the input parameters x and t, and Vmath.h is the value obtained using the math.h function us 1.6484 - 1.648721 1.648721 * 1001 0.0195 Using these values, the program should display a table like: result 1.6484 math.h 1.6487 error 0195 0.5 4

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions