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/Exercises/C14/ex3.c

34 lines
769 B
C
Raw Permalink 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() {
int degrees_start, degrees_end;
float radians, sin_val, cos_val, tan_val;
printf("Start: ");
scanf("%d", &degrees_start);
printf("End: ");
scanf("%d", &degrees_end);
printf("Degs\tRad\tsin\tcos\ttan\n");
for (int i = degrees_start; i <= degrees_end; i++) {
process((float)i, &radians, &sin_val, &cos_val, &tan_val);
printf("%d\t%0.3f\t%0.3f\t%0.3f\t%0.3f\n", i, radians, sin_val, cos_val, tan_val);
}
}