C++ examples for Language Basics:Console
Demonstrate need for setw manipulator
#include <iostream> #include <iomanip> using namespace std; int main()//from www. j a v a2s.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; }