Contoh program dengan procedure n function

program contoh_function;

uses crt;

var n:integer;

function jumgan(var y:integer):integer;

var xx:integer;

begin

xx:=0;

while y>=1 do

begin

xx:=xx+y;

y:=y-2;

end;

jumgan:=xx;

end;

begin

write(‘masukkan bilangan bulat =  ‘);readln(n);

if (n mod 2 = 0) then n:=n-1;

writeln(‘ JUMLAH GANJIL DARI ‘,n:5,’  adalah ‘, jumgan(n):8);

end.

About boruhasibuan

sabar, berjuang, dan semangat yg disertai kemauan dan do'a dlm menghadapi sgala sesuatu hal, ini-lah yg selalu ada dlm pikiran-Q, berjuang dan berjuang!!!!
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s