-
Lenguaje
Pascal
-
Descripción
Algoritmo para capturar un dato numérico entero, de acuerdo a las reglas de negocios que se describen a continuación:
- Como salida mostrar en pantalla si el dato es positivo o negativo.
- Como salida mostrar en pantalla si el dato es par o impar.
- Como salida mostrar el valor absoluto del dato.
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
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
program SignoParidadYValorAbsoluto;
uses crt;
var absoluto, dato_numerico_entero : integer;
begin
write ('Ingresa el valor de dato numerico entero: ');
readln (dato_numerico_entero);
if dato_numerico_entero<0 then
begin
writeln ('Negativo');
absoluto := -dato_numerico_entero;
end
else
begin
writeln ('Positivo');
absoluto := dato_numerico_entero;
end;
if dato_numerico_entero mod 2=0 then
begin
writeln ('Par');
end
else
begin
writeln ('Impar');
end;
writeln ('Valor de absoluto: ', absoluto);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var absoluto, dato_numerico_entero : integer;
begin
write ('Ingresa el valor de dato numerico entero: ');
readln (dato_numerico_entero);
if dato_numerico_entero<0 then
begin
writeln ('Negativo');
absoluto := -dato_numerico_entero;
end
else
begin
writeln ('Positivo');
absoluto := dato_numerico_entero;
end;
if dato_numerico_entero mod 2=0 then
begin
writeln ('Par');
end
else
begin
writeln ('Impar');
end;
writeln ('Valor de absoluto: ', absoluto);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.