-
Lenguaje
Pascal
-
Descripción
Reciba una determinada cantidad de números y en seguida imprima su suma y su promedio.
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
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
program SumaYPromedioDeNNumeros;
uses crt;
var i, n : integer;
var promedio, suma, un_numero : real;
begin
promedio := 0;
suma := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de un numero: ');
readln (un_numero);
suma := suma+un_numero;
writeln;
end;
if n = 0 then
promedio := 0
else
promedio := suma/n;
writeln ('Valor de promedio: ', promedio:0:6);
writeln ('Valor de suma: ', suma:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var i, n : integer;
var promedio, suma, un_numero : real;
begin
promedio := 0;
suma := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de un numero: ');
readln (un_numero);
suma := suma+un_numero;
writeln;
end;
if n = 0 then
promedio := 0
else
promedio := suma/n;
writeln ('Valor de promedio: ', promedio:0:6);
writeln ('Valor de suma: ', suma:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.