#include <stdio.h>
#include <math.h>
void compute_trig(float deg, float* sin_angle, float* cos_angle);
int main(void)
{
float sin_result = 0.0f;
float cos_result = 0.0f;
float angle = 0.0f;
printf("Angle? \n");
scanf("%f", &angle);
// TODO: Call compute_trig
compute_trig(angle,&sin_result,&cos_result);
printf("sin(%f) is %f\n", angle, sin_result);
printf("cos(%f) is %f\n", angle, cos_result);
return 0;
}
void compute_trig(float deg, float* sin_angle, float* cos_angle)
{
float pi = 3.14159f;
float radians = deg * pi / 180.0f;
// TODO: Compute sine angle...
*sin_angle = sinf(radians);
// TODO: Compute cosine angle...
*cos_angle = cosf(radians);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter