Q: Write a program to compute the value of sin(x) using built-in function and using user-defined function (your own function), then print out the result. The values of x=30,45,60,90,180. Write the output of the built-in function and user-defined function.
when I answered the Q I tried all angels and the answer true but when I entered 180 and 360 consul gave me :
enter any degree
180
sin (x) = -8.74228e-08
but the answer should be 0
the code :
#include <iostream>
#include <math .h>
using namespace s td;
float F1(float x) {
x = (x*3.14159265359) / 180;
x = sin(x);
return x;
}
int main() {
float y;
cout << "enter any degree"<<end l;
cin >> y;
y = F1(y);
cout << "sin (x) = " << y;
return 0;
}