There are two kind of subroutine in Pascal : Function and Procedure. The difference between these subroutines is in return value. Function gives a return value, but procedure doesn’t. The structure of function and procedure are the same :
Here is the example of procedure and function :
program FunctionAndProcedure;{$APPTYPE CONSOLE}
uses
SysUtils;
procedure Add1(x, y : integer);
var
z : integer;
begin
z := x + y;
writeln(x,' + ',y,' = ',z,' (using procedure)');
readln;
end;
function Add2(x, y : integer) : integer;
begin
Add2 := x + y;
end;
begin
Add1(25,10);
writeln('25 + 40 = ',Add2(25,40),' (using function)');
readln;
end.
You can download the complete code here.
berkunjung ke tempat kawan untuk mencari ilmu yang tercecer
ReplyDeletemoga sukses selalu kawan
dari t4 Pakde sulas di ajak mampir kesini ..
ReplyDeleteikut menyimak dan belajar sobb
Refreshing.. dulu pernah belajar tapi lupa lagi sob.
ReplyDeleteTFS
penulisan fungsinya di atas pakai bahasa apa ya??
ReplyDeleteAPTIMASTERS is basically an online aptitude site which provides the help for the students to make their aptitude skills more enhanced so that they can overcome the entrance examinations for CAT,MAT,UPSC ,Placement Exams etc .
ReplyDeletes The best and a lot of secret drop-shipping suppliers in the world which will provide your products globally available for you directly to your customers doors. Also get the best drop-shipping manufacturer on your organization.
ReplyDelete