- Back to Home »
- PASCAL »
- array
Posted by : Unknown
Minggu, 01 Desember 2013
program tugas_2;
uses wincrt;
var
jum,rata,nilai:real;
n,i:byte;
nama:string;
nim:longint;
a:array[1..100] of integer;
max,min:real;
begin
writeln('Mencari Nilai Max,Min,Jumlah
dan Rata-rata');
write('Nama : ');readln(nama);
write('Nim : ');readln(nim);
writeln;
writeln('=======================');
writeln('Masukkan banyak nilai yang akan
diinputkan: ');readln(n);
jum:=0;
for i:=1 to n do
begin
writeln('Masukkan nilai ke' ,i,':
');readln(a[i]);
jum:=Jum+a[i];
rata:=jum/n;
writeln('=============');
end;
writeln('Jumlah = ',jum:4:2);
writeln('rata-rata = ',rata:4:2);
begin
max:=a[1];
min:=a[1];
for i:= 2 to n do
if a[i]>max then max:=a[i]
else if a[i]<min then min:=a[i];
writeln('');
writeln('Nilai Maksimum ',max:0:0);
writeln('Nilai Minimum ',min:0:0);
readln;
end;
end.
hasil running