C++ Programming in easy steps, 6th Edition by Mike McGrath

C++ Programming in easy steps, 6th Edition by Mike McGrath

Author:Mike McGrath
Language: eng
Format: epub
Publisher: In Easy Steps
Published: 2022-02-11T00:00:00+00:00


manipulate.cpp

Add a main function containing a final return statement and declaring two initialized variables

int main()

{

bool isTrue = 1 ;

int num = 255 ;

// Add more statements here.

return 0 ;

}

In the main function, insert statements to set the width and fill of an output stream, then output a text string on it

cout.width( 40 ) ;

cout.fill( ‘.’ ) ;

cout << “Output” << endl ;

Next, insert statements to set the precision of an output stream to stop truncation of decimal places – then output a floating point number showing all its decimal places

cout.precision( 11 ) ;

cout << “Pi: ” << 3.1415926536 << endl ;

Now, insert statements that use manipulators to output the variable values in modified formats

cout << isTrue << “: ” << boolalpha << isTrue << endl ;

cout << num << “: ” << hex << showbase << uppercase << num << endl ;

Save, compile, and run the program to see the output



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.