math library functions: log10, fabs, ceil, floor : Math « Development « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;
using std::fixed;

#include <iomanip>
using std::setprecision;

#include <cmath>
using namespace std; 

int main()
{
   cout << fixed << setprecision( 1 ); 

   cout << "\nlog10(" << 1.0 << ") = " << log10( 1.0 )<< "\nlog10(" << 10.0 <<) = " << log10( 10.0 ) 
      << "\nlog10(" << 100.0 << ") = " << log10( 100.0 ) ;
   cout << "\nfabs(" << 13.5 << ") = " << fabs( 13.5 )<< "\nfabs(" << 0.0 << ") = " << fabs( 0.0 )
      << "\nfabs(" << -13.5 << ") = " << fabs( -13.5 );
   cout << "\nceil(" << 9.2 << ") = " << ceil( 9.2 )<< "\nceil(" << -9.8 << ")= " << ceil( -9.8 );
   cout << "\nfloor(" << 9.2 << ") = " << floor( 9.2 )<< "\nfloor(" << -9.8 <<) = " << floor( -9.8 );
   return 0;
}
log10(1.0) = 0.0
log10(10.0) = 1.0
log10(100.0) = 2.0
fabs(13.5) = 13.5
fabs(0.0) = 0.0
fabs(-13.5) = 13.5
ceil(9.2) = 10.0
ceil(-9.8) = -9.0
floor(9.2) = 9.0
floor(-9.8) = -10.0








5.19.Math
5.19.1.Use the abs() function
5.19.2.Create Random number
5.19.3.Use math function: sqrt, pow, log
5.19.4.Use math function: cos, sin, tan
5.19.5.Raise x to the y power
5.19.6.math library functions: log10, fabs, ceil, floor
5.19.7.math library functions: pow, fmod, sin, cos, tan