Thursday, 24 January 2013

program 2-5(51) Demonstrate set width manipulatore

// Demonstrate the use of set width manipulator.
#include <iostream>

#include <iomanip>
using namespace std;

int main()
{
    cout << "results \n";

    //variables
    int num1 = 321;
    int num2 = 231;

// setw examples
    cout << num1 << num2  << "\t | no setw \n";

    cout << setw(1) << num1 << setw(1)<< num2 << "\t | 1 setw \n";

    cout << setw(5) << num1 << setw(5) << num2 << "\t | 5 setw \n";

    cout << setw(10) << "hallo" << "\t | string setw 10 \n";

    cout << setw(3) << "hallo" << "\t | string setw 3 \n";

    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    cin.get();
    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