Tuesday 12 February 2013

Manipulators in C++ Programming Language



Manipulators are functions used with the insertion operator (<<). These are used to format the data to be displayed. They are,

1) endl
2) setw

1) endl - end line

This function is used to transfer the control to a new line while printing.

Example:
cout<<"Name :"<<name<<endl<<"Age"<<age;

2) setw - set width

This function is used to set the width of the output list. The list may be variables or constants. The output is right justified.

The general form is

setw(size).

where
size - number of characters to be displayed. This should be an integer.


0 comments:

Post a Comment

Powered by Blogger.