What is manipulator?
0 minute read
What is manipulator?
· Manipulators are operators that are used to format the data display.
· The most commonly used manipulators are endl and setw.
· The endl manipulator is used in an output statement for linefeed.
· endl has the same effect as using the newline character “\n”.
For example, the statement.
cout << ”M = ” << endl;
cout << “N = ” << endl;
would cause two lines of output, one for each variable.
· setw is used to set the common field width.
Example:
cout << setw(5) << N << endl;
cout << n << endl << X;
The manipulator setw (5) specifies a field width 5 for printing the value of the variable M, N and X.