-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseccion_3_5.c
More file actions
59 lines (43 loc) · 1.25 KB
/
Copy pathseccion_3_5.c
File metadata and controls
59 lines (43 loc) · 1.25 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
/*
Sección 3.5. - Ejemplo Práctico Funciones y Control de Flujo
Objetivo:
*/
#include <stdio.h>
int main(void) {
int opcion;
int numero;
int i;
do {
printf("\nMenú:\n");
printf("1) Verificar si el número es par o impar\n");
printf("2) Imprimir tabla de multiplicar (1 al 10)\n");
printf("3) Salir\n");
printf("Elige una opción: ");
scanf("%d", &opcion);
switch (opcion) {
case 1:
printf("Ingresa un número entero: ");
scanf("%d", &numero);
if (numero % 2 == 0) {
printf("El número es par.\n");
} else {
printf("El número es impar.\n");
}
break;
case 2:
printf("Ingresa un número entero: ");
scanf("%d", &numero);
for (i = 1; i <= 10; i++) {
printf("%d x %d = %d\n", numero, i, numero * i);
}
break;
case 3:
printf("Saliendo...\n");
break;
default:
printf("Opción inválida.\n");
break;
}
} while (opcion != 3);
return 0;
}