Jumat, 02 Maret 2012

menghitung (pascal)


uses crt;

var data : array [1..100] of integer;
    i, n, jum, max, min : integer;
    rata : real;


begin
write('Banyak Data: ');
readln(n);

for i := 1 to n do
    begin
    write('Data ',i,' : ');
    read(data[i]);
    jum := jum + data[i];
    end;

    rata := jum/n;

    max := data[1];
    min := data[1];

for i := 2 to n do
    begin
    if data[i] > max then max := data[i];
    if data[i] < min then min := data[i];
    end;

    writeln('---------------------');

for i := 1 to n do

    write(data[i],' ');
    writeln('  ');
    writeln('---------------------');
    writeln('Jumlah        : ',jum);
    writeln('Rata-Rata     : ',rata:0:2);
    writeln('Data Terbesar : ',max);
    writeln('Data Terkecil : ',min);
  readln;
  readln;
end.

Tidak ada komentar:

Posting Komentar