-
Notifications
You must be signed in to change notification settings - Fork 1
/
Ejercicio1.4.c
114 lines (114 loc) · 1.69 KB
/
Ejercicio1.4.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include<stdio.h>
#include<math.h>
const float PI=3.1415;
void Menu(),FT(),FM(),Show(float),M1(int);
float ConvertToRadian(float),Sin(float),Cos(float),Tan(float),Raiz(float),Pot(float,float),lg(float);
int main(){
Menu();
}
void M1(int x){
if(x==0) printf("1) Funciones trigonometricas\n2)Funciones Matematicas\n3)Salir\n");
else if(x==1) printf("1) Seno\n2) Coseno\n3) Tangente\n4)Regresar\n");
else printf("1) Potencia\n2) Raiz\n3) Logaritmo\n4) Regresar\n");
}
float Input(){
float x;
scanf("%f",&x);
return x;
}
void Show(float x){
printf("%f\nDesea continuar? 1=y/2=n\n",x);
float z=Input();
if(z==1) Menu();
}
void Menu(){
M1(0);
int x=Input();
switch(x){
case 1:
FT();
break;
case 2:
FM();
break;
default:
printf("Error");
break;
}
}
void FT(){
M1(1);
int x=Input();
float r,s;
switch(x){
case 1:
s=Input();
r=Sin(s);
Show(ConvertToRadian(r));
break;
case 2:
s=Input();
r=Cos(s);
Show(ConvertToRadian(r));
break;
case 3:
s=Input();
r=Tan(s);
Show(ConvertToRadian(r));
break;
case 4:
Menu();
break;
default:
Menu();
break;
}
}
void FM(){
M1(2);
int x=Input();
float s,r,p;
switch(x){
case 1:
s=Input();
p=Input();
r=Pot(s,p);
Show(r);
break;
case 2:
s=Input();
r=Raiz(s);
break;
case 3:
s=Input();
r=lg(s);
break;
case 4:
Menu();
break;
default:
Menu();
break;
}
}
float ConvertToRadian(float x){
return x*(PI/180);
}
float Sin(float x){
return sin(x);
}
float Cos(float x){
return cos(x);
}
float Tan(float x){
return tan(x);
}
float Pot(float x,float y){
return pow(x,y);
}
float Raiz(float x){
return sqrt(x);
}
float lg(float x){
return log(x);
}