Line Up Columns of Numbers - C++ File Stream

C++ examples for File Stream:cout

Description

Line Up Columns of Numbers

Demo Code

#include <iostream>
using namespace std;
int main()/*from  www .ja va 2  s .  c o m*/
{
   cout << "Root | Square |    Cube\n";
   for(int i = 1; i < 11; ++i) {
      cout.width(4);
      cout << i << " |";
      cout.width(7);
      cout << i * i << " |";
      cout.width(8);
      cout << i * i * i;
      cout << endl;
   }
   return 0;
}

Result


Related Tutorials