-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseccion_2_6.c
More file actions
32 lines (23 loc) · 756 Bytes
/
Copy pathseccion_2_6.c
File metadata and controls
32 lines (23 loc) · 756 Bytes
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
/*
Sección 2.6. - Ejemplo Práctico Construyendo un Programa Simple
Objetivo: Integrar variables, operadores y scanf/printf en un programa simple
*/
#include <stdio.h>
int main(void) {
double x, y;
printf("Ingresa el primer número: ");
scanf("%lf", &x);
printf("Ingresa el segundo número: ");
scanf("%lf", &y);
double suma = x + y;
double resta = x - y;
double multiplicacion = x * y;
double division = x / y; // Nota: aquí asumimos que 'y' no es 0
// Lo validaremos en el siguiente bloque
printf("\nResultados:\n");
printf("x + y = %.2lf\n", suma);
printf("x - y = %.2lf\n", resta);
printf("x * y = %.2lf\n", multiplicacion);
printf("x / y = %.2lf\n", division);
return 0;
}