Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3.3 Write the C++ statements that compute x1 and x2 using 3? calls to predefined functions. Hint: you need to compute one square root

Exercise 3.3 Write the C++ statements that compute x1 and x2 using 3? calls to predefined functions. Hint: you need to compute one square root and two powers, i.e., you will use the sqrt once and the pow twice. ?? Round up and Round down Functions Sometimes, you may want to round your numbers up or down. There are two predefined functions that are used for this purpose. The function ceil will round up a given real number to its next whole number and function floor will round down a given real number to its lower whole number. They do not follow conventional rounding rules, and only round to whole numbers. Examples: if x = 34.3 then y = ceil(x) is 35.0 if x = 34.3 then y = floor(x) is 34.0 Exercise 3.4 Answer the following questions: A) What are the ceil and floor of 34.6? B) What are the ceil and floor of -33.2? C) Round 34.2, 34.6, -33.2 and -33.7. D) Suggest a method to round a number using ceil or floor, then apply it to the numbers in part C. Absolute Value of Integer and Real Values In C++ we have two functions that are used to find the absolute value of an integer or a real value. The first one is called abs that is used to compute the absolute value of an integer. Example: x = -4, then y = abs(x) will be 4. The other function is fabs that computes the absolute value of a float or double type number. Example: x = -3.43, then y = fabs(x) will be 3.43.

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

More Books

Students also viewed these Databases questions