Create a table of log10 and log from 2 through 100. : cout width « Console « C++






Create a table of log10 and log from 2 through 100.

Create a table of log10 and log from 2 through 100.
 

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  double x;

  cout.precision(5);
  cout << "         x       log x        ln e\n\n";

  for(x = 2.0; x <= 100.0; x++) {
    cout.width(10);
    cout << x << "  ";
    cout.width(10);
    cout << log10(x) << "  ";
    cout.width(10);
    cout << log(x) << '\n';
  }
 
  return 0;
}



           
         
  








Related examples in the same category

1.Set cout lengthSet cout length
2.Left-justification and right-justification.
3.cout: width(), precision(), and fill(). cout: width(), precision(), and fill().