Thursday, 24 January 2013

program 2-8(54) Demonstrate fixed-point manipulator

// this program demonstrate the fixed-point manipulator.
#include <iostream>
#include <limits>
#include <iomanip>
using namespace std;

int main()
{
    // variables.
    float x = 1;
    float y = 1.2345;
    float z = 1234.89;

    // process

   cout << x << "\t | with no manipulators" << "\n" << y << "\n" << z << "\n" << "\n";

   cout << fixed;
   cout << x << "\t | with manipulator fixed" << "\n" << y << "\n" << z << "\n" << "\n";

   cout << setprecision(2);
   cout << x << "\t | with manipulator setprecision(2)" << "\n" << y << "\n" << z << "\n" << "\n";

   cout << showpoint;
   cout << x << "\t | with manipulator showpoint" << "\n" << y << "\n" << z << "\n" << "\n";




    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    return 0;
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management