Question: Exercise 2 (30%) Please write a C++ program to read an integer x and output f(x) rounded to three decimal places, where the f(x) is

 Exercise 2 (30%) Please write a C++ program to read an

Exercise 2 (30%) Please write a C++ program to read an integer x and output f(x) rounded to three decimal places, where the f(x) is defined as follows: 2x2 +5, f(x) = X-2 4 if x is odd if x is even 1 Some sample runs are shown as follows (underlined bold characters in blue are user input): Sample Run 1 Input x: 3 f(x) = 4.796 Sample Run 2 Input x: -5 f(x) = 7.416 Sample Run 3 Input x: 12 f(x) = 2.500 Please name your C++ source file as Lab1Ex2.cpp

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!