Tuesday, January 20, 2009

Find the biggest end the 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 maksimum_minimum;
uses wincrt;
var i, j, maks,min,n : integer;
    x : array [1..100] of integer;
begin
     write('Write Sum Of Data : ');readln(n);
     for i:= 1 to n do
         begin
           write('Data[',i,'] : ');readln(x[i]);
         end;
     maks:= x[1];
     min := x[i]; j:=1;
     for j :=1 to n do
     begin
          if x[j] > maks then maks := x[j] else maks := maks;
          if x[j] < min then min := x[j] else min := min;
     end;
     writeln;
     writeln('Sum of data : ',n);
     writeln('Maksimum Number : ', maks);
     writeln('Minimum Number  : ', min);
end.
    


And if you ran this program yau can get output loke this :




No comments: