PROGRAM arraysample;
USES crt;
TYPE
angka=ARRAY[1..20] OF integer;
VAR
nilai:angka;
i,n,jum:integer;
FUNCTION input(x:integer):integer;
BEGIN
jum:=0;
FOR i:=1 TO x DO
BEGIN
write('Data ke-',i,' : ');readln(nilai[i]);
jum:=jum+nilai[i];
END;
END;
PROCEDURE output(y:integer);
BEGIN
writeln('Data yang tadi dimasukkan : ');
FOR i:=1 TO y DO
BEGIN
write(nilai[i],' ');
END;
END;
PROCEDURE MID(z:integer);
BEGIN
writeln('Data pertama : ',nilai[1]);
writeln('Data tengah : ',nilai[z div 2 + 1]);
writeln('Data terakhir : ',nilai[z]);
writeln('---------------------------');
writeln('Jumlah total data : ',jum);
writeln('Rata-rata data : ',jum/n:0:2);
END;
BEGIN
clrscr;
writeln('Membuat deret data dengan ARRAY');
writeln('===============================');
write('Masukkan banyak data (bilangan ganjil maks 20) = ');readln(n);
input(n); writeln;
output(n); writeln;
writeln;
MID(n);
readln;
END.
Tidak ada komentar:
Posting Komentar