#include <stdio.h>
#include <math.h>

double toRad(double deg) {
    double rad;
    rad = deg * M_PI/180;
    return rad;
}

double norma(double x,double y) {
    return sqrt( pow(x,2.0) + pow(y,2.0) );
}

int main() {
    double deg, rad,x,y,n;

    // i radianti sono definit in [0,2π)
    for( deg = 0.0; deg <= 360.0; deg += 45.0 ) {
        rad = toRad( deg );    
        rad = fmod(rad, 2*M_PI);
        x = sin(rad);
        y = cos(rad);
        n = norma(x,y);
        
        printf("deg = %lf --> |(%.2lf,%.2lf)|=%.2lf\n", deg,x,y,n);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: