Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- double intoRadians(double fdegree);
- double trygonometric_calc(double fdegree, int func_choiсe);
- int main()
- {
- int func_choice;
- double degree;
- puts("Choice the function to calculate(1 - sin, 2 - cos, 3 - tan, 4 - cot):");
- // Почитай почему %u
- scanf("%u", &func_choice);
- puts("Enter the degree:");
- scanf("%lf", °ree);
- printf("Result: %lf", trygonometric_calc(degree, func_choice));
- system("pause");
- return 0;
- }
- double intoRadians(double fdegree)
- {
- return (fdegree * 3.14) / 180;
- }
- double trygonometric_calc(double fdegree, int func_choice)
- {
- if ( (func_choice > 4) || (func_choice < 1))
- {
- puts("Invalid input");
- exit(0);
- }
- switch (func_choice)
- {
- case 1:
- return sin(intoRadians(fdegree));
- case 2:
- return cos(intoRadians(fdegree));
- case 3:
- return tan(intoRadians(fdegree));
- case 4:
- return 1 / tan(intoRadians(fdegree));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement