setPrecisionFixed

setPrecisionFixed - /Example: setprecision, fixed,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//Example: setprecision, fixed, showpoint, setw, right and left / #include <iostream> #include <iomanip> #include <string> # using namespace std; u int main() { double x,y,z; string name = "john smith" ; s x = 15.67; x y = 235.73; y z = 9525.9864; z cout<<fixed<<showpoint; c cout << setprecision(2)<<"Line 5: setprecision(2)"<<endl; c cout<<"Line 6: x = "<<setw(12)<<x<<endl; c cout<<"Line 7: y = "<<setw(12)<<y<<endl; c cout<<"Line 8: z = "<<setw(12)<<z<<endl; c cout << setw(25)<<name << endl; c cout<<left << setprecision(2)<<"Line 5: setprecision(2) and left"<<endl; c cout<<"Line 6: x = "<<setw(12)<<x<<endl; c cout<<"Line 7: y = "<<setw(12)<<y<<endl; c cout<<"Line 8: z = "<<setw(12)<<z<<endl; c cout << setw(25)<<name << endl; c cout<<right << setprecision(2)<<"Line 5: setprecision(2) and right"<<endl; c cout<<"Line 6: x = "<<setw(12)<<x<<endl; c cout<<"Line 7: y = "<<setw(12)<<y<<endl; c cout<<"Line 8: z = "<<setw(12)<<z<<endl; c cout << setw(25) << name << endl; c cout<<setprecision(3)<<"Line 9: setprecision(3)"<<endl;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

setPrecisionFixed - /Example: setprecision, fixed,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online