C++ const define PI value

Description

C++ const define PI value

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()/*from   w  w w.j a v  a  2s  .  co  m*/
{
   const double PI = 3.1416;
   const double DEG_TO_RAD = PI/180.0;
   double angle;
   cout << "Enter the angle (in degrees): ";
   cin  >> angle;
   cout << setiosflags(ios:: fixed) << setiosflags(ios::showpoint) << setprecision(4) << "The sine of the angle is " << sin(angle * DEG_TO_RAD) << endl;
   return 0;
}



PreviousNext

Related