C++ cout setw manipulator

Description

C++ cout setw manipulator

#include <iostream>
using namespace std;
int main()/*  www  .  j ava 2s .  co m*/
{
   long pop1=1111111, pop2=47, pop3=9761;
   cout << "LOCATION " << "POP." << endl
   << "Portcity " << pop1 << endl
   << "Hightown " << pop2 << endl
   << "Lowville " << pop3 << endl;
   cout << setw(8) << "LOCATION" << setw(12)
   << "POPULATION" << endl
   << setw(8) << "Portcity" << setw(12) << pop1 << endl
   << setw(8) << "Hightown" << setw(12) << pop2 << endl
   << setw(8) << "Lowville" << setw(12) << pop3 << endl;
   return 0;
}



PreviousNext

Related