Trigonometry Function Table

Hello, this is my 2nd time posting here. My prof said that in order to use trigonometric function, I need to convert the angle from degrees to radian. My idea is to define the angle in degrees in term of z. ie: z = angle * ( PI / 180)
But then I don't know how to proceed giving the value of angle. How can I assign the values for my angles?

If my code is already wrong from the start please tell me.

My code need to give the following output:

Enter an angle between -360 and 360 degrees: -180
Enter an angle between -360 and 360 degrees: 180
Angle (degrees) cos sin cosh sinh
-180.0 -1.00 -0.00 11.59 -11.55
180.0 -1.00 0.00 11.59 11.55

This code is as far as I can go right now.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>		//Preprocessor Directive
#include <iomanip>
#include<math.h>

const	double	PI	=	acos(-1.0);		//	value	of	pi

int main()
{
 	
	double z1, z2, angle1, angle2, v, w, x, y;  	
  
    z1 = angle1 * ( PI / 180.0 );
  	z2 = angle2 * ( PI / 180.0 );
  	v = cos ( z1 ) , cos ( z2 );
	w = sin ( z1 ) , sin ( z2 );
	x = cosh ( z1 ) , cosh ( z2 );
	y = sinh ( z1 ) , cosh ( z2 );
  
	cout << z1 
      
  	cout << "Enter an angle between -360 and 360 degrees: ";
    cin >> angle1;
    
    cout << "Enter an angle between -360 and 360 degrees: ";
    cin >> angle2;
    
    
  
  
  
	return 0;
  
}
On line 12 you do use the value of 'angle1'. What is the value at that point? The variable was declared on line 10, but it has not been initialized with known value, nor set to specific value before line 12. In other words, at that point the value of angle1 is undefined.


On line 22 the user gives a (presumably) valid value for angle1 (in degrees). If you want to convert that value into radians, surely you must do it after you have got the value?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
using std::setw;

const double PI = acos(-1.0);

int main()
{
  	double angle1, angle2, w1, w2, x1, x2, y1, y2, z1, z2, sum;
	cout << "Enter an angle between -360 and 360 degrees: ";
    cin >> angle1;
    
    cout << "Enter an angle between -360 and 360 degrees: ";
    cin >> angle2;
  
  	w1 = cos(angle1 * PI / 180.0);
  	x1 = sin(angle1 * PI / 180.0);
  	y1 = cosh(angle1 * PI / 180.0);
  	z1 = sinh(angle1 * PI / 180.0);
  
  	cout << " " << setw(15) << angle1;
  	cout << setw(9) << round(w1);
  	cout << setw(9) << round(x1);
  	cout << setw(9) << round(y1);
  	cout << setw(9) << round(z1) << endl;
  
  	w2 = cos(angle2 * PI / 180.0);
  	x2 = sin(angle2 * PI / 180.0);
  	y2 = cosh(angle2 * PI / 180.0);
  	z2 = sinh(angle2 * PI / 180.0);
  
  	cout << " " << setw(15) << angle2;
  	cout << setw(9) << round(w2);
  	cout << setw(9) << round(x2);
  	cout << setw(9) << round(y2);
  	cout << setw(9) << round(z2) << endl;
    	
  	return 0;
}


I already done this far. But my result don't have the same output. And the value for sinh, cosh do not have decimal places.
What does the round() do? Check its documentation.
Topic archived. No new replies allowed.