displaying sine/cos/tan in a program

I'm in a programming class and we're using Starting out With C++ by Tony Gaddis (5th Ed.) as a text. I haven't had any form of a math class in like 3 years and I'm only taking this because it's a requirement for my Media Informatics major. I know nothing about C++ and it would be an understatement to say that everything I've learned in it is very, very above my comprehension level. A problem we have to answer is to have the user of the program enter the measurement of an angle in radians and then we have to display the sine, cosine and tangent of the angle-- however, I have no idea how to write this or find it out in a program. Any assistance would be greatly appreciated! Thanks!
You'll have to include <cmath> and link with the math library (on the command line that's:
-lm
) to use the sine, cosine, etc. functions. This site has a very nice reference for the <cmath> library and the functions available.

Your program should:
- ask for the user to enter the angle (use cout)
- read the angle from the user (use cin)
- use the sin() function to get the sine of the angle
- tell the user what you are displaying and display it (using cout)
- repeat for cos() and tan()
- that's it

Hope this helps.
#include <iostream.h>
#include<cmath.h>
void main(){
double angle;
cout<<"enter the angle";
cin>>angle;
cout<<sin(angle);
cout<<cos(angle);
cout<<tan(angle);
}
Topic archived. No new replies allowed.