precision and printing out digits

For my lab, I am trying to print out the value of sine using a function. The printed value should display 5 digits after the decimal. However, the angle that is being used is also printing out 5 digits. For example, it prints out like sin(45.00000) when I want it to look like sin(45). I think it has something to do with the first bit of code in int main(). Can someone help?

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
42
43
44
45
46
#include <iostream>
#include <cmath>
const double PI = 3.14159;
using namespace std;

double degreestoRadians (double Degrees)
{
	return (Degrees * 3.14159/180);
}

int drawLine (char c, int numRepetitions) // print out character numRepetitions times
{
	int Line; 
	
	for (int i = 1; i <= numRepetitions; i++)
		cout << '-';
		
	return (Line);
}

int main ()
{
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(5); // show five digits to the right of decimal
	
	double valueOfSine;
	double angle;
	char Line;
	
	for (int i = 0; i <= 360; i += 5)
	{
	    angle = i;
	    valueOfSine = degreestoRadians(angle); // calling function degreestoRadians in main
	    cout << "sin("<< angle <<") = " << sin(valueOfSine) << endl;
        
        if ((angle == 0) || (angle == 90) || (angle == 180) || (angle == 270) || (angle == 360))	    
	    {
	        Line = drawLine('-', 30); // calling function drawLine in main
	        cout << endl;
	    }
	}

	return 0;
}
cout << "sin("<< i <<") = " << sin(valueOfSine) << endl;
Topic archived. No new replies allowed.