Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ 1. Computation (25%] The formula f has two inputs: n (date type: int) and x (date type: double). The result of f is also
c++
1. Computation (25%] The formula f has two inputs: n (date type: int) and x (date type: double). The result of f is also double type. f = n/(x+/1 + x2 /2 + x3/3 + ... +x" ) Write a program according to the following requirements: For the inputs of n and x, we assume that they are already the int-type and double-type numbers, respectively, i.e., you do not need to check whether they are belonged to any other data types. . For the input n, please check whether it is positive. If no, ask the user to input n again. Next, for the input x, check whether 0.1 sx s 1. If no, ask the user to input x again. If both n and x are valid, please use the loop statements to compute the value of f and output the result with only two digits in the decimal part. Note 1: Your code should NOT use the function pow(x,i). Note 2: You can compute the denominator first f = x1/1 + x2 /2 + x3/3 + ... +x" and then f = n/f. Example-1 (Inputs are underlined): Please input n (positive): 3 Please input x (0.1Step 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