Monday, February 2, 2009

Find biggest and smallest number

To find the biggest end the smallest number of suite number,in this case I am use array type.
To fing it we must compare indeks[1] with other indeks.We can use indeks[1] (i[1]) for the reference.
We can compare the indeks with statement like this:


program bil_kecil_besar;
uses wincrt;
var dafbil : array [1..100] of integer;
terbesar,terkecil : integer;
i,n : integer;

begin
writeln('masukan jumlah bilangan imputan');
readln(n);
for i:=1 to n do
begin
write('bilangan ke-',i,'=') ; read(dafbil[i]);
end;
terbesar := dafbil[1];
terkecil := dafbil[1];
for i:=2 to n do
if dafbil[i] > terbesar then
terbesar := dafbil[i]
else
if dafbil[i] < style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 95px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihkSTnjFOj4UO05jBVUVzz-pfaL5PuwkvpoLDWiku61hpRGimvgX6nbzfUufDWdzeuF_RvTsjVnI6rh1UN2kG5bUniNAQAywmzboIiUIyxrHLntiCsR2lIrr4c7huOgA1-jIfKSn9iMTI/s400/besar+kecil.jpg" alt="" id="BLOGGER_PHOTO_ID_5298001271877449042" border="0">

No comments: