Διαδικασίες, συναρτήσεις και τάξεις
Παράδειγμα συνάρτησης και διαδικασίας σε Pascal
program fun;
(* Παραγοντικό του Ν *)
function factorial(N : Integer) : Integer;
var
Count, Result : Integer;
begin
Count := N;
Result := 1;
While Count > 0 Do
begin
Result := Result * Count;
Count := Count - 1
end;
Factorial := Result
end (* Factorial *);
procedure clear_screen;
const number_of_lines = 24;
var i : integer;
begin
for i := 0 to number_of_lines do
writeln('');
end (*clear_screen*);
begin
clear_screen;
writeln(factorial(5));
end.
Παράδειγμα κλάσης σε Java
class Point extends Object {
private int x;
private int y;
public void MoveTo(int x, int y) {
this.x = x;
this.y = y;
}
public int GetX() {
return (x);
}
}