#include <stdio.h>
#include <math.h>
double to_rad(double deg) {
double rad = 0.0;
// prima riduco all'intervallo [0...360)
deg = fmod(deg, 360.0);
// poi applico il fattore di conversione
rad = deg * M_PI / 180;
return rad;
}
int main() {
int deg;
double rad;
for(deg = 0; deg <= 360; deg += 15) {
rad = to_rad(deg);
printf("%-3d = %lf --> (%.2lf,%.2lf)\n", deg, rad, sin(rad), cos(rad));
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: