C++ for Engineers and Scientists
C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
bartleby

Videos

Textbook Question
Book Icon
Chapter 6.2, Problem 11E

(Numerical) a. The following is an extremely useful programming algorithm for rounding a real number to n decimal places:

Step 1: Multiply the number by 10 n

Step 2: Add 0.5

Step 3: Delete the fractional part of the result

Step 4: Divide by 10 n

For example, using this algorithm to round the number 78.374625 to three decimal places yields:

S t e p   1 :   78.374625   ×   103   =   78374.625 S t e p   2 :   78374.625   +   0.5   =   78375.125 S t e p   3 :   R e t a i n i n g   t h e   i n t e g e r   p a r t   =   78375 S t e p   4 :   78375   d i v i d e d   b y   103   =   78.375

Using this algorithm, write a C++ function that accepts a user-entered value and returns the result rounded to two decimal places.

b. Enter, compile, and run the program written for Exercise 11a.

Blurred answer
Students have asked these similar questions
"Do not use AI tools. Solve the problem by hand on paper only and upload a photo of your handwritten solution."
| √ (r² + r + 1)e^ dr
Ensure you answer the question asked at the end of the document. Do not just paste things without the GNS3 console outputs
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License