Ch3_setPrecisionFixed

Ch3_setPrecisionFixed - //Line 10 cout...

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

View Full Document Right Arrow Icon
//Example: setprecision, fixed, showpoint #include <iostream> #include <iomanip> # using namespace std; u int main() { double x, y, z; x = 15.674; //Line 1 y = 235.73; //Line 2 z = 9525.9864; //Line 3 cout << fixed << showpoint; //Line 4 cout << setprecision(2) << "Line 5: setprecision(2)" << endl; //Line 5 cout << "Line 6: x = " << x << endl; //Line 6 cout << "Line 7: y = " << y << endl; //Line 7 cout << "Line 8: z = " << z << endl; //Line 8 cout << setprecision(3) << "Line 9: setprecision(3)" << endl; //Line 9 cout << "Line 10: x = " << x << 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 10 cout &lt;&lt; &quot;Line 11: y = &quot; &lt;&lt; y &lt;&lt; endl; //Line 11 cout &lt;&lt; &quot;Line 12: z = &quot; &lt;&lt; z &lt;&lt; endl; //Line 12 cout &lt;&lt; setprecision(4) &lt;&lt; &quot;Line 13: setprecision(4)&quot; &lt;&lt; endl; //Line 13 cout &lt;&lt; &quot;Line 14: x = &quot; &lt;&lt; x &lt;&lt; endl; //Line 14 cout &lt;&lt; &quot;Line 15: y = &quot; &lt;&lt; y &lt;&lt; endl; //Line 15 cout &lt;&lt; &quot;Line 16: z = &quot; &lt;&lt; z &lt;&lt; endl; //Line 16 cout &lt;&lt; &quot;Line 17: &quot; &lt;&lt; setprecision(3) &lt;&lt; x &lt;&lt; &quot; &quot; &lt;&lt; setprecision(2) &lt;&lt; y &lt;&lt; &quot; &quot; &lt;&lt; setprecision(4) &lt;&lt; z &lt;&lt; endl; //Line 17 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