Hi all,
Now, I'm trying practice on c++ basics, since few minutes I tried practice "library functions" especially "sin" function, I wrote this trivial program to calculate angle in console screen, but when I input 90 degree it gave me 0.8939, but with calculator it gave me 1, why console can not gave my integer answer like calculator..?

This is my code:

//calculate sin angle | library functions
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	double angle, answer;

	cout << "Enter Angle: ";
	cin  >> angle;
	answer = sin(angle);
	cout << "sin " << angle << " is = " << answer << endl;

	return 0;
}
#include <iostream>
#include <cmath>

using namespace std;
#define PI 3.14

int main(){	

	 
	 //calculate sin angle | library functions
	double angle, angle_rad, answer;

	cout << "Enter Angle in degrees: ";
	cin  >> angle;
	angle_rad = PI*angle/180;
	answer = sin(angle_rad);
	cout << "sin " << angle << " is = " << answer << endl;
	cin.get();
	return 0;
	
}

Thanks helping me for all..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.