-
Lenguaje
Pascal
-
Descripción
Capturar m número indeterminado de números y sumar los pares al final mostrar la suma total y la cantidad de números recibidos.
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
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
program SumaDeParesYTotal;
uses crt;
var numeros_recibidos, suma_total, sumar_de_pares, un_numero : integer;
var tecla_repetir : char;
begin
numeros_recibidos := 0;
sumar_de_pares := 0;
suma_total := 0;
repeat
clrscr;
write ('Ingresa el valor de un numero: ');
readln (un_numero);
if un_numero mod 2=0 then
begin
sumar_de_pares := sumar_de_pares+un_numero;
end;
numeros_recibidos := numeros_recibidos+1;
suma_total := suma_total+un_numero;
writeln;
write (#168'Deseas repetir el proceso? (S/N): ');
repeat
tecla_repetir := readkey;
until (tecla_repetir = 's') or (tecla_repetir = 'n') or (tecla_repetir = 'S') or (tecla_repetir = 'N');
until (tecla_repetir <> 's') and (tecla_repetir <> 'S');
writeln ('Valor de numeros recibidos: ', numeros_recibidos);
writeln ('Valor de sumar de pares: ', sumar_de_pares);
writeln ('Valor de suma total: ', suma_total);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var numeros_recibidos, suma_total, sumar_de_pares, un_numero : integer;
var tecla_repetir : char;
begin
numeros_recibidos := 0;
sumar_de_pares := 0;
suma_total := 0;
repeat
clrscr;
write ('Ingresa el valor de un numero: ');
readln (un_numero);
if un_numero mod 2=0 then
begin
sumar_de_pares := sumar_de_pares+un_numero;
end;
numeros_recibidos := numeros_recibidos+1;
suma_total := suma_total+un_numero;
writeln;
write (#168'Deseas repetir el proceso? (S/N): ');
repeat
tecla_repetir := readkey;
until (tecla_repetir = 's') or (tecla_repetir = 'n') or (tecla_repetir = 'S') or (tecla_repetir = 'N');
until (tecla_repetir <> 's') and (tecla_repetir <> 'S');
writeln ('Valor de numeros recibidos: ', numeros_recibidos);
writeln ('Valor de sumar de pares: ', sumar_de_pares);
writeln ('Valor de suma total: ', suma_total);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.