These are the operators that are used to format data display.
(i) end l manipulator
when it is used is an output statement,causes a line feed to be inserted. It has the same effect as using new line character "n".
e.g. the statement
cout<<"m="<<m end l;
cout<<"n="<<n end l;
cout<<"p="<<p end l;
would cause three lines of output, one for each variable. If values of the variable are assumed as
2597,14 and 175 respectively, then output will appear as follows:
this is the value of m.
this is the value of n.
this is the value of p.
This is not an ideal output but it should appear rather as follows:
this is the value of m.
this is the value of n.
this is the value of p.
(ii) set w manipulators
It is used as follows:
cout<<set w(5)<<sum<<end l;
Manipulator set w(5) specifies a field width 5 for printing value of the variable sum. This value is right
justified within the field as shown below:
Use of manipulators.
# include<iostream.h>
#include<iomanip.h>// to set w
main()
{
int Basic=950, Allowance=95
Total=1045;
cout<< set w (10)<<"Basic" << set w (10) << Basic << end l
<< set w (10)<<"Allowances" << set w (10) << Allowances << end l
<< set w (10)<<"Total" << set w (10) << Total << end l
Output of this program is
Basic 950
Allowances 95
Total 1045
0 Comment(s)