setw ( ) manipulator :-It's full form is set width and it is used to set the width of the output statement or screen. Mean's by using this manipulator we can restrict our output to the digits to which we want. The reference can be given by setw (n).
Where n specifies the width of the out put screen and is an integer value. And if we want to use this manipulator then a header file <iomanip> is used because setw ( ) is part of this header file.
The proper syntax is given below :
#include <iostream>
#include <iomanip>
using namespace std;
int main ( )
{
cout << setw (10) << "Asia" << setw (8) << "Europe";
return 0;
}
No comments:
Post a Comment