program max_min;
uses crt;
var
a : array [1..100] of integer;
b,c : integer;
jumlah : longint;
min,max : real;
begin
writeln('Program Mencari Nilai Maximum dan Minimum');
writeln('Banyak Data yang akan diinput : ');readln(b);
jumlah := 0;
for c:= 1 to b do
begin
write('Masukkan data ke-',c,'=');readln(a[c]);
jumlah:=jumlah+a[c];
end;
begin
clrscr;
max := a[1];
min := a[1];
for c := 2 to b do
if a[c] > max then max := a[c]
else if a[c] < min then
min := a[c];{mencari nilai maximum dan minimum}
writeln('');
writeln('Nilai Minimum = ',min:0:2);
writeln('Nilai Maximum = ',max:0:2);
readln;
end;
end.
uses crt;
var
a : array [1..100] of integer;
b,c : integer;
jumlah : longint;
min,max : real;
begin
writeln('Program Mencari Nilai Maximum dan Minimum');
writeln('Banyak Data yang akan diinput : ');readln(b);
jumlah := 0;
for c:= 1 to b do
begin
write('Masukkan data ke-',c,'=');readln(a[c]);
jumlah:=jumlah+a[c];
end;
begin
clrscr;
max := a[1];
min := a[1];
for c := 2 to b do
if a[c] > max then max := a[c]
else if a[c] < min then
min := a[c];{mencari nilai maximum dan minimum}
writeln('');
writeln('Nilai Minimum = ',min:0:2);
writeln('Nilai Maximum = ',max:0:2);
readln;
end;
end.
0 comments:
Posting Komentar