Write a program that prints the value 100.453627 rounded to the nearest digit, tenth, hun- dredth, thousandth and ten-thousandth.

What will be an ideal response?


```
#include
#include
using namespace std;

int main()
{
double x = 100.453627; // value to test precision outputs

cout << fixed; // display output using fixed-point notation

// display output using loop counter as precision
for ( int loop = 0; loop <= 5; loop++ )
cout << setprecision( loop ) << "Rounded to " << loop
<< " digit(s) is " << x << endl;
} // end main
```
Rounded to 0 digit(s) is 100
Rounded to 1 digit(s) is 100.5
Rounded to 2 digit(s) is 100.45
Rounded to 3 digit(s) is 100.454
Rounded to 4 digit(s) is 100.4536
Rounded to 5 digit(s) is 100.45363

Computer Science & Information Technology

You might also like to view...

To _______ multiple style sheets to a compound document, you add a separate processing instruction for each style sheet.

A. import B. include C. link D. combine

Computer Science & Information Technology

Define an exception class called DimensionException to use in the driver program from Programming Project 4 in Chapter 8. Modify that driver program to throw and catch a DimensionException if the user enters something less than or equal to zero for a dimension.

This project is fairly simple. The DimensionException class is written to accept a String and an integer so the message can be more helpful (it can display which dimension is invalid and its value). The MoreGraphicsDemo program from Chapter 8 Programming Project 4 is modified to create the version using DimensionException and to be interactive so the exception code can be exercised.

Computer Science & Information Technology

Identify the letter of the choice that best matches the phrase or definition.

A. The property that moves an element up if its value is positive B. Shifting the element's position from the point where it normally would appear in the document flow C. A software add-on used to enhance a particular browser D. An element that marks content that is not the main content E. The row that appears on the top of the Web page F. A div element created for formatting purposes that contains one or more elements G. Describes how the contents of a page are recognized by the browser H. A space between the section column and the main column I. The text used to demonstrate the typography or layout in a document J. A type of layout in which the column widths don't change when the browser window changes size K. A layout that does not appear on the screen as planned L. A layout that expands or contracts so the content fills the entire screen

Computer Science & Information Technology

What is Triple Data Encryption Standard (3DES)?

What will be an ideal response?

Computer Science & Information Technology