-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculadoraFuncion.cpp
77 lines (62 loc) · 1.34 KB
/
calculadoraFuncion.cpp
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
#include <iostream>
using namespace std;
bool menu(int*, int*, int*);
void suma(int, int, int*);
void resta(int, int, int*);
void multiplicacion(int, int, int*);
void division(int, int, int*);
/* comentario random en el proyecto */
int main()
{
int x, y, z, operacion;
if(menu(&x, &y, &z))
cout << "El resultado es: " << x << endl;
else
cout << "Operacion incorrecta" << endl;
system("pause");
return 1;
}
bool menu(int* x, int* y, int* z){
int operacion;
bool resp = true;
cout << "Ingrese el primer numero" << endl;
cin >> *y;
cout << "Ingrese el segundo numero" << endl;
cin >> *z;
cout << "Ingrese la operacion (Suma = 1, Resta = 2, Multiplicacion = 3, Division = 4)" << endl;
cin >> operacion;
switch (operacion)
{
case 1:
suma(*y, *z, x);
break;
case 2:
resta(*y, *z, x);
break;
case 3:
multiplicacion(*y, *z, x);
break;
case 4:
division(*y, *z, x);
break;
default:
resp = false;
break;
}
return resp;
}
void suma(int a, int b, int* c){
*c = a + b;
}
void resta(int a, int b, int* c){
*c = a - b;
}
void multiplicacion(int a, int b, int* c){
*c = a * b;
}
void division(int a, int b, int* c){
if(b == 0)
*c = 0;
else
*c = a / b;
}