// // Filename: pgm3_a.cpp // // Description: Demonstration of Math Library functions #1 // // ENSC 104: Digital Computer Programming // // Instructor: Dr. Walsh // // Section: 2 // // Date Created: 02/23/98 // Last Modified: 02/23/98 // // Name: N/A // #include #include const float PI = 3.1415926; const float PI_OVER_TWO = PI/2.0; const float PI_OVER_FOUR = PI/4.0; main() { float x; float y; float z; x = 9.0; y = sqrt( x ); cout << "sqrt(" << x << ") = " << y << endl << endl; x = 1.0; y = exp( x ); cout << "exp(" << x << ") = " << y << endl << endl; x = 2.9; y = log( x ); cout << "log(" << x << ") = " << y << endl << endl; x = 10000.0; y = log10( x ); cout << "log10(" << x << ") = " << y << endl << endl; x = -1.23; y = fabs( x ); cout << "fabs(" << x << ") = " << y << endl << endl; x = 1.23; y = ceil( x ); cout << "ceil(" << x << ") = " << y << endl << endl; x = 1.23; y = floor( x ); cout << "floor(" << x << ") = " << y << endl << endl; x = 2.1; y = 3.2; z = pow( x, y ); cout << "pow(" << x << ", " << y << ") = " << z << endl << endl; x = 26.34; y = 20.0; z = fmod( x, y ); cout << "fmod(" << x << ", " << y << ") = " << z << endl << endl; x = PI_OVER_FOUR; y = sin( x ); cout << "sin(" << x << ") = " << y << endl << endl; x = PI_OVER_FOUR; y = cos( x ); cout << "cos(" << x << ") = " << y << endl << endl; x = PI_OVER_FOUR; y = tan( x ); cout << "tan(" << x << ") = " << y << endl << endl; return 0; }