-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodigo.txt
More file actions
112 lines (83 loc) · 2.24 KB
/
Copy pathcodigo.txt
File metadata and controls
112 lines (83 loc) · 2.24 KB
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
int sumar(int a, int b) {
int resultado = a + b;
return resultado;
};
float dividir(float a, float b) {
float resultado = a / b;
return resultado;
};
string saludar(string nombre) {
string mensaje = "Hola ";
return mensaje + nombre;
};
bool esMayor(int edad) {
bool resultado = edad >= 18;
return resultado;
};
MiPrograma {
int x = 10;
int y = 20;
if (x < y) {
mostrar("Hola, bienvenido!");
} else {
mostrar("Adiós, hasta luego!");
};
int sumaTotal = 0;
int i = 1;
for (i = 1; i <= 5; i = i + 1) {
sumaTotal = sumaTotal + i;
};
mostrar("La suma total del for es :", sumaTotal);
int contador = 0;
while (contador < 3) {
mostrar("Ciclo while en ejecución...");
contador = contador + 1;
};
int num = 5;
int b = 10;
int c = 20;
int suma = num + b;
mostrar("suma:", suma);
int resta = c - num;
mostrar("resta:", resta);
int multiplicacion = num * b;
mostrar("Multiplicación:", multiplicacion);
float division = c / num;
mostrar("División:", division);
if (c != b) {
mostrar("c es diferente de b");
};
if (b >= num) {
mostrar("b es mayor o igual que num");
};
float resultadoFinal = (suma + resta) * (multiplicacion - division);
mostrar("Resultado final:", resultadoFinal);
string nombre = "Sofia";
string saludo = "¡Hola ";
string despedida = "Adiós ";
mostrar(saludo, nombre, "!");
mostrar(despedida, nombre, "!");
bool mayorEdad = true;
bool menorEdad = false;
if (mayorEdad) {
mostrar(nombre, " es mayor de edad.");
};
if (menorEdad == false) {
mostrar(nombre, " no es menor de edad.");
};
bool comparacion = x > 5;
if (comparacion) {
mostrar("x es mayor que 5");
};
# --- PRUEBAS DE FUNCIONES ---
int total = sumar(5, 15);
mostrar("Resultado de sumar:", total);
float divReal = dividir(10.0, 4.0);
mostrar("Resultado de dividir:", divReal);
string saludoPersonal = saludar(nombre);
mostrar("Saludo personalizado:", saludoPersonal);
bool esAdulto = esMayor(20);
if (esAdulto) {
mostrar(nombre, " es adulto.");
};
}