C++ cout setw()
Control the field width to leave gap between two values
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main()//from w w w . j ava 2 s. co m { const int MAXCOUNT = 5; int count; cout << "NUMBER SQUARE ROOT\n"; cout << "------ -----------\n"; cout << setiosflags(ios::showpoint); for (count = 1; count <= MAXCOUNT; count++) cout << setw(4) << count << setw(15) << sqrt(double(count)) << endl; return 0; }