Pascal (Fungsi hitung sederhana)

Fungsi dalam pascal, contoh sederhana :

uses crt;
function hitung(var a,b:integer):integer;
begin
hitung:=a+b;
end;
var
x,y:integer;
begin
write(‘Nilai X ? ‘);readln(x);
write(‘Nilai Y ? ‘);readln(y);
writeln;
writeln(x,’+’,Y,’=’,Hitung(x,y));
readln;
end.

Maka Akan tampil :

Nilai X ? 5
Nilai Y ? 6

5 + 6 = 11

Iklan

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