Algoritma & Program MaxMin

Posted: 25 Maret 2014 in Strategi Algoritma

2
Source Code Pascal :

//Algoritma :
Program MaxMin;
//{ diberikan bilangan bulat , kemudian tampilkan bilangan terbesar dan terkecil }

//Deklarasi :

uses wincrt;
var bil :array[1..100] of integer;
max,min,i,n :integer;
begin

//Deskripsi :
write(‘Masukkan n =’);readln(n);
for i:= 1 to n do
begin
write(‘Bilangan ke ‘,i,’ = ‘);readln(bil[i]);
end;
max:=bil[1];
min:=bil[1];
for i:= 2 to n do
if bil[i] > max then
max:=bil[i]
else
if bil[i] < min then
min:=bil[i];
writeln(‘Bilangan terbesar =’,max);
writeln(‘Bilangan terkecil =’,min);
end.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s