devxlogo

Right-Justification of Output

Right-Justification of Output

To right justify the output of cout, call the width() function with the size of the output screen (in characters) as an argument. In the following example, the program calls width() to right-justify a number that is displayed on a standard screen of 80 characters:

 #include using namespace std;int main(){ int var=15; cout.width(80); cout << var << endl; // right-justified display}

devx-admin

Share the Post: