Tech Me All

Tips ,Tricks notes and Quizes

USE OF MANIPULATORS IN C++

USE OF MANIPULATORS

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void main()

{

cout<<setw(7);

cout<<setfill(‘#’);

cout<<endl<<178;

cout<<setw(4);

cout<<endl<<21;

cout<<setw(12);

cout<<endl<<1234<<32<<452;

cout<<setprecision(2);

cout<<endl<<123.235;

cout<<endl<<345.5056;

getch();

}

Output:

p1

 

Discretion: The function setw() is a set width used to set the lenth of number , setfill() is set the character to fill in blank spaces in the value and endl is a end line used to move the pointer to the next line.setprecision( )  is used to set the precision of the value to show.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 15 =

Tech Me All © 2016 Frontier Theme