This repository has been archived on 2023-10-26. You can view files and clone it, but cannot push or open issues or pull requests.
VSMechatronics/C14/ex2.c

30 lines
647 B
C
Raw Normal View History

2023-10-06 15:44:56 +00:00
#include <stdio.h>
#include <math.h>
float degrees_to_radians(float degrees) {
return M_PI * degrees / 180.0;
}
void process(float degrees, float* radians, float* sin_val, float* cos_val, float* tan_val) {
*radians = degrees_to_radians(degrees);
*sin_val = sin(*radians);
*cos_val = cos(*radians);
*tan_val = tan(*radians);
}
int main() {
float degrees, radians, sin_val, cos_val, tan_val;
printf("Degrees: ");
scanf("%f", &degrees);
process(degrees, &radians, &sin_val, &cos_val, &tan_val);
printf("Radians: %f\n", radians);
printf("Sine: %f\n", sin_val);
printf("Cosine: %f\n", cos_val);
printf("Tangent: %f\n", tan_val);
}