#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 << "\npow(" << 2.0 << ", " << 7.0 << ") = " << pow( 2.0, 7.0 ) << "\npow(" << 9.0 << ", "
<< 0.5 << ") = " << pow( 9.0, 0.5 );
cout << setprecision(3) << "\nfmod("<< 13.675 << ", " << 2.333 << ") = " << fmod( 13.675, 2.333 ) << setprecision( 1 );
cout << "\nsin(" << 0.0 << ") = " << sin( 0.0 );
cout << "\ncos(" << 0.0 << ") = " << cos( 0.0 );
cout << "\ntan(" << 0.0 << ") = " << tan( 0.0 ) << endl;
return 0;
}
pow(2.0, 7.0) = 128.0
pow(9.0, 0.5) = 3.0
fmod(13.675, 2.333) = 2.010
sin(0.0) = 0.0
cos(0.0) = 1.0
tan(0.0) = 0.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 |