Wednesday, April 30, 2014

program mencari nilai max-min

program Max_Min;
uses wincrt;
var a:array[1..100] of integer;
    i,n: byte;
    max,min:integer;
    coba:char;
begin
    clrscr;
    coba:='y';
    while coba='y' do
begin
    writeln ;
    write('masukkan banyak data: '); readln(n);
    max:=0; min:=9999 ;
    clrscr;
    for i :=1 to n do begin write('masukkan nilai angka',i,': ');readln(a[i]);
    if max <(a[i])then max :=(a[i]);
    if min >(a[i])then min:=(a[i]);
end;
    writeln('nilai maksimal: ',max);
    writeln('nilai minimal: ',min);
    writeln;
    writeln;
    write ('Coba Program Lagi? [y/t]: ');
    readln(coba);
    if coba='y' then coba:= 'y';
end;
    readln;
end.

No comments:

Post a Comment