-
Lenguaje
Pascal
-
Descripción
Leer un número entero de tres cifras y determinar si la suma de sus dígitos es un número par o impar. Ejemplo: la suma de los dígitos del número 354 es par porque 3+4+5 es igual a 12.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
program SumaDe3CifrasParOImpar;
uses crt;
var numero, suma : integer;
begin
write ('Ingresa el valor de numero: ');
readln (numero);
suma := (numero mod 1000-numero mod 100) div 100+(numero mod 100-numero mod 10) div 10+numero mod 10;
if suma mod 2=0 then
begin
writeln ('Par');
end
else
begin
writeln ('impar');
end;
writeln ('Valor de suma: ', suma);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var numero, suma : integer;
begin
write ('Ingresa el valor de numero: ');
readln (numero);
suma := (numero mod 1000-numero mod 100) div 100+(numero mod 100-numero mod 10) div 10+numero mod 10;
if suma mod 2=0 then
begin
writeln ('Par');
end
else
begin
writeln ('impar');
end;
writeln ('Valor de suma: ', suma);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.