cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
sin cos tang
sin cos tang
Oct 2, 2011 at 9:53pm UTC
kcomp11
(41)
I want the user to input a degree of an angle and then use that degree and do the sin cos and tang function but so far no luck
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
const int PI = 3.14;
float degree;
cout << "Please enter the degee of the angle." <<endl;
cin >> degree;
cout << setprecision(4) << fixed <<endl;
cout << sin((PI/180)*degree);
system("pause");
return 0;
}
Oct 2, 2011 at 10:01pm UTC
Athar
(4466)
You're assigning 3.14 to an integer. It should be a double.
As a result, integer division is being performed further down (3/180 is 0) and so you're printing sin(0) every time.
Topic archived. No new replies allowed.