-
Lenguaje
Pascal
-
Descripción
Una empresa registra el sexo, edad y estado civil de sus empleados a través de un número entero positivo de cuatro cifras de acuerdo a lo siguiente: la primera cifra de la izquierda representa el estado civil (1 para soltero, 2 para casado, 3 para viudo y 4 para divorciado), las siguientes dos cifras representan la edad y la tercera cifra representa el sexo (1 para femenino y 2 para masculino). Determinar el estado civil, edad y sexo de un empleado conociendo el número que empaqueta dicha información.
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
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
program EstadoCivilEdadYSexo;
uses crt;
var edad, estado_civil, informacion, sexo : integer;
begin
write ('Ingresa el valor de informacion: ');
readln (informacion);
estado_civil := (informacion mod 10000-informacion mod 1000) div 1000;
if estado_civil=1 then
begin
writeln ('Soltero');
end;
if estado_civil=2 then
begin
writeln ('Casado');
end;
if estado_civil=3 then
begin
writeln ('Viudo');
end;
if estado_civil=4 then
begin
writeln ('Divorciado');
end;
edad := (informacion mod 1000-informacion mod 10) div 10;
sexo := informacion mod 10;
if sexo=1 then
begin
writeln ('Femenino');
end;
if sexo=2 then
begin
writeln ('Masculino');
end;
writeln ('Valor de edad: ', edad);
writeln ('Valor de estado civil: ', estado_civil);
writeln ('Valor de sexo: ', sexo);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var edad, estado_civil, informacion, sexo : integer;
begin
write ('Ingresa el valor de informacion: ');
readln (informacion);
estado_civil := (informacion mod 10000-informacion mod 1000) div 1000;
if estado_civil=1 then
begin
writeln ('Soltero');
end;
if estado_civil=2 then
begin
writeln ('Casado');
end;
if estado_civil=3 then
begin
writeln ('Viudo');
end;
if estado_civil=4 then
begin
writeln ('Divorciado');
end;
edad := (informacion mod 1000-informacion mod 10) div 10;
sexo := informacion mod 10;
if sexo=1 then
begin
writeln ('Femenino');
end;
if sexo=2 then
begin
writeln ('Masculino');
end;
writeln ('Valor de edad: ', edad);
writeln ('Valor de estado civil: ', estado_civil);
writeln ('Valor de sexo: ', sexo);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.