Senin, 19 Mei 2014

PROGRAM MENCARI MAX,MIN DAN RATA-RATA DALAM PASCAL

program MaxdanMin;
uses wincrt;
        var a : array[1..100] of integer;
        i,n,max,min,jum:integer;
        rata : real;
begin
        write('masukkan banyak data :');
        read(n);
        for i:=1 to n do
        begin
                write('data ke-',i, '= ');
                read(a[i]);
                jum := jum + a[i];
                end;

                rata:=jum/n;

                max := a[1];
                min := a[1];
        for i:=2 to n do
        begin
                if max < (a[i]) then max:=(a[i]);
                if min > (a[i]) then min:=(a[i]);
                end;

        writeln('jumlah : ',jum);
        writeln('nilai max :',max);
        writeln('nilai min :',min);
        writeln('rata - rata :',rata:0:2);
        readkey;
        end.



fahmi,s blogPosted By Fahmi's BLog

Semoga informasi yang Fahmi's sampaikan sangat bermanfaat bagi Kita semua contact me

Thank You

1 komentar: