(. subroutine) , . . .
, . , .
, . ( ) : ( , , ), , , .
, , , , , ...
́ . , , , , .
, (, ), . , , . , , .
(, ) (, ), , , C, ( ).
, ( , , - ). , ( , , ), , - . , , . , . , , , , . .
|
|
- , , . - :
function :
function <> ( ): <>;
;
- ,
< > (< >).
Function < >( : ): ;
Var
, . .
, ( , , ). , , . .
:
- ( );
- ( );
- ( 7.0);
- - (. . ).
, , , - - - . , . , . , . ,
function Max(A: arrayt1..100] of Real): Real;
, -, :
type tArr = arrayt1..100] of Real; function Max(A: tArr): Real;
.
- , ( ) begin. - ,
function name_of_f unction (argumentslist): type_of_result;
|
|
type_of_result , () name_of_function. argumentslist . -. . . .
- , , , begin . - end, , . - . . - , , .
- - . , . .
N.
function Factorial(N: Byte): Longint;
var Fact: Longint;
i: Byte;
begin
Fact:= N;
for i: = N-l downto 2 do
Fact: = Fact * i;
Factorial:= Fact
end;
Program ProcedureAndFunction;
Uses
Crt;
Var
a, b, SumNumbers: integer;
Procedure Summa1(Var Sum: integer; a, b: integer);
Begin
Sum:= a+b;
End;
Function Sum(a, b: integer): integer;
Begin
Sum:= a+b;
End;
Begin
ClrScr;
a:= 12;
b:= 15;
Summa1(SumNumbers, a, b);
writeln (' ',SumNumbers);
writeln (' ',Sum(a, b));
End.