Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As you learned in the chapter, you must be careful when comparing two real numbers for either equality or inequality because some real numbers cannot

As you learned in the chapter, you must be careful when comparing two real numbers for either equality or inequality because some real numbers cannot be stored precisely in memory. To determine whether two real numbers are either equal or unequal, you should test that the difference between both numbers is less than some acceptable small value, such as 0.00001.
a. Start your C++ development tool, and view the Advanced16.cpp file. The file is contained in either the Cpp8\Chap05\Advanced16 Project folder or the Cpp8|Chap05 folder. (Depending on your C++ development tool, you may need to open this exercise's solution/project file first.) The code divides the contents of the num 1 variable (10.0) by the contents of the num 2 variable (3.0), storing the result (approximately 3.33333) in the quoti ent variable. An if statement is used to compare the contents of the quoti ent variable with the number 3.33333. The if statement displays a message that indicates whether the numbers are equal.
b. Run the program. Even though the message on the screen states that the quotient is 3.33333, the message indicates that this value is not equal to 3.33333. Close the Command Prompt window.
image text in transcribed

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

Students also viewed these Databases questions