Selasa, 14 April 2015

Program Pointer Menggunakan Bahasa Pascal

Source Code


uses crt;
type pointer=^string;
var
a,b, c, d : pointer;
       nilai : String;


begin
clrscr;
nilai := 'ini adalah string nilai';
a := @nilai;
New(b);
New(d);
b^ := 'ini isi pointer b';
c := b; {c menunjuk ke yang ditunjuk b}
d^ := b^;
writeln('alamat pointer a = ', seg(a^):4,' : ', ofs(a^):4, ' isi pointer a = ', a^);
writeln('alamat pointer b = ', seg(b^):4,' : ', ofs(b^):4, ' isi pointer b = ', b^);
writeln('alamat pointer c = ', seg(c^):4,' : ', ofs(c^):4, ' isi pointer c = ', c^);
writeln('alamat pointer d = ', seg(d^):4,' : ', ofs(d^):4, ' isi pointer d = ', d^);
readln;
end.

Selasa, 07 April 2015

PROGRAM SEARCHING PADA PASCAL



 Source Code
program searching;
uses crt;

label awal;

var pil:char;
    lg :char;

const nmin = 1;
      nmax = 100;

type  arrint = array [nmin..nmax] of integer;

var tabint : arrint;
    x,n,i,indeks,max,min,maks : integer;

function seqsearch1(xx : integer): integer;
  var i : integer;
  begin
    i := 1;
    while ((i<n) and (tabint[i] <> xx)) do
      i:=i+1;
      if tabint[i] = xx then
        seqsearch1:=i
        else
        seqsearch1:=0;
  end;

function maksimum (tabint: arrint; n : integer) : integer;
  var i, max : integer;
  begin
   for i:=2 to n do
   if max<tabint[i] then
   max:=tabint[i];
   maksimum:=max;
  end;

function minimum (tabint: arrint; n : integer) : integer;
  var i, min : integer;
  begin
   for i:=1 to n do
   if min>tabint[i] then
   min:=tabint[i];
   minimum:=min;
  end;


begin
  clrscr;
  writeln;
  write('Masukkan Jumlah Data = '); readln(n);
  writeln;
  Clrscr;
  for i:=1 to n do
    begin
       write('   Data[',i,'] = '); readln(tabint[i]);
     end;
    writeln;
        write ('  Nilai yang dicari : '); readln(x);
    indeks:=seqsearch1(x);
      if indeks <> 0 then
      write ('  Nilai : ',x,' ditemukan pada indeks ke-',indeks)
       else
      write('   Nilai : ',x,'tidak ditemukan !');
      writeln;


    begin
    writeln;
    maks:=maksimum(tabint,n);
    min:=minimum(tabint,n);
    writeln;
    writeln ('  Nilai maksimum : ',maks);
    writeln ('  Nilai minimum  : ',min );
    readkey;
    end;
         end.