-
Lenguaje
Pascal
-
Descripción
Lea número 1, numero 2 y opción, si la opción es 1 sume n1 y n2, si es 2 los reste, si es 3 los multiplique y si es 4 los divida.
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
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
program OperacionesCon2Numeros;
uses crt;
var n1, n2, opcion, resultado : real;
begin
write ('Ingresa el valor de n1: ');
readln (n1);
write ('Ingresa el valor de n2: ');
readln (n2);
write ('Ingresa el valor de opcion: ');
readln (opcion);
resultado := 0;
if opcion=1 then
begin
resultado := n1+n2;
end;
if opcion=2 then
begin
resultado := n1-n2;
end;
if opcion=3 then
begin
resultado := n1*n2;
end;
if opcion=4 then
begin
resultado := n1/n2;
end;
writeln ('Valor de resultado: ', resultado:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var n1, n2, opcion, resultado : real;
begin
write ('Ingresa el valor de n1: ');
readln (n1);
write ('Ingresa el valor de n2: ');
readln (n2);
write ('Ingresa el valor de opcion: ');
readln (opcion);
resultado := 0;
if opcion=1 then
begin
resultado := n1+n2;
end;
if opcion=2 then
begin
resultado := n1-n2;
end;
if opcion=3 then
begin
resultado := n1*n2;
end;
if opcion=4 then
begin
resultado := n1/n2;
end;
writeln ('Valor de resultado: ', resultado:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.