Programa que calcula el promedio de N valores dados
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 | {-Victor De la Rocha} {-Algoritmia@groups.msn.com} {-www.myalgorithm.com} uses crt;type vector=array [1..100] of integer; var arreglo:vector; cantidad,cont,suma:integer;begin ClrScr; Write('Cantidad de valores: ');Readln(cantidad); writeln; suma:=0; for cont:=1 to cantidad do begin Write('Valor ',cont,': ');Readln(arreglo[cont]); end; for cont:=1 to cantidad do begin suma:=suma+arreglo[cont]; end; Write('promedio: ',suma/cantidad:0:2); ReadKey; end. |
Cantidad: 27
Valor 1: 67
Valor 2: 7
Valor 3: 6
Valor 4: 36
Valor 5: 33
Valor 6: 80
Valor 7: 76
Valor 8: 31
Valor 9: 11
Valor 10: 93
Valor 11: 37
Valor 12: 52
Valor 13: 49
Valor 14: 57
Valor 15: 12
Valor 16: 86
Valor 17: 43
Valor 18: 30
Valor 19: 74
Valor 20: 65
Valor 21: 39
Valor 22: 23
Valor 23: 43
Valor 24: 74
Valor 25: 36
Valor 26: 95
Valor 27: 92
Promedio: 49.8888888889