Friday, July 31, 2009

In C++ programming what dose function setw() do in this library <iomainp>??

It specifies the width of the display field

In C++ programming what dose function setw() do in this library %26lt;iomainp%26gt;??
setw() function will allocate the space of the outputs in the screen or printer.


It you give


int i=100;


cout%26lt;%26lt;setw(5)%26lt;%26lt;i;


The output will be


100 // that measn right justified for numbers.


//left justfied for characters


cout%26lt;%26lt;setw(6,4)%26lt;%26lt;17.5


output will be


17.50 // totally 6 and 4 for decimals





check for your own coding. This will be useful.


No comments:

Post a Comment