-
Lenguaje
Pascal
-
Descripción
Lea dos números, reste ambos y muestre el resultado en positivo y en negativo.
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
program RestaEnPositivoYNegativo;
uses crt;
var a, b, resultado_negativo, resultado_positivo : real;
begin
write ('Ingresa el valor de a: ');
readln (a);
write ('Ingresa el valor de b: ');
readln (b);
if a>b then
begin
resultado_positivo := a-b;
resultado_negativo := b-a;
end
else
begin
resultado_positivo := b-a;
resultado_negativo := a-b;
end;
writeln ('Valor de resultado negativo: ', resultado_negativo:0:6);
writeln ('Valor de resultado positivo: ', resultado_positivo:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var a, b, resultado_negativo, resultado_positivo : real;
begin
write ('Ingresa el valor de a: ');
readln (a);
write ('Ingresa el valor de b: ');
readln (b);
if a>b then
begin
resultado_positivo := a-b;
resultado_negativo := b-a;
end
else
begin
resultado_positivo := b-a;
resultado_negativo := a-b;
end;
writeln ('Valor de resultado negativo: ', resultado_negativo:0:6);
writeln ('Valor de resultado positivo: ', resultado_positivo:0:6);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.