calculating sin, cos, and tangent function
I am trying to calculate sin, cos, and tan. The program works but it gives it to me in radians. I needed the conversion to degrees which is sin(x) * PI / 180. when i do this it gives me the wrong answer, can someone help me out. this is my code:
#include <iostream>
using namespace std;
#include <iomanip>
#include <cmath>
const PI = 3.14159265359;
int main()
Code:
{
// constant variable can be used to specify array size
const int arraySize = 45;
int s[ arraySize ]; // array s has 45 elements
cout << fixed << setprecision(6);
for ( int i = 1; i <= arraySize; i++ ) // set the values
s[i] = i++;
cout <<"Angle\n" << "(Degrees)" << setw( 9 ) <<"Sine"<< setw(15)
<<"Cosine"<< setw(14) <<"Tangent"<<endl;
// output contents of array s in tabular format
for ( int j = 1; j <= arraySize; j++ )
cout << setw( 2 ) << j << setw( 20 ) << sin(j) << setw(13)
<< cos(j * PI * 180) << setw(13) << tan(j) << endl;
return 0;
} // end main