Ch3_setw - /Line 7 cout<< setprecision(2/Line 8...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Example: setw #include <iostream> #include <iomanip> # using namespace std; u int main() { int x = 19; //Line 1 int a = 345; //Line 2 double y = 76.384; //Line 3 cout << fixed << showpoint; //Line 4 cout << "12345678901234567890" << endl; //Line 5 cout << setw(5) << x << endl; //Line 6 cout << setw(5) << a << setw(5) << "Hi" << setw(5) << x << endl << endl;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //Line 7 cout << setprecision(2); //Line 8 cout << setw(6) << a << setw(6) << y << setw(6) << x << endl; //Line 9 cout << setw(6) << x << setw(6) << a << setw(6) << y << endl << endl; //Line 10 cout << setw(5) << a << x << endl; //Line 11 cout << setw(2) << a << setw(4) << x << endl; //Line 12 return 0; }...
View Full Document

This note was uploaded on 03/08/2011 for the course CSIT 139 taught by Professor Duzut during the Spring '11 term at Los Angeles City College.

Ask a homework question - tutors are online