What is manipulator and What is the use of manipulators in CPP?

Practice # 8.1

#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int a=5b=50c=5060;
    cout<<"it is the value of a : "<<a<<endl;   
    cout<<"it is the value of b : "<<b<<endl;
    cout<<"it is the value of c : "<<c<<endl;
    // Here is the 'endl' is a manipulator
    // 'endl is use for new line
    cout<<"it is the value of a : "<<setw(5)<<a<<endl;
    cout<<"it is the value of b : "<<setw(5)<<b<<endl;
    cout<<"it is the value of c : "<<setw(5)<<c<<endl;
    /* then practice the new manipulator
    is 'setw'. It come "iomanip" header file.*/

    return 0;
}

Comments