Program Structure

Procedures that do not return a value:

Scheme (define (graph1) ...)
Pascal procedure graph1; begin ... end;
C++ void graph1() { ... }
Java public static void graph1() { ... }

Functions that return a value:

Scheme (define (factorial n) ...)
Pascal function factorial(n:integer):integer; ...
C++ int factorial(int n) { ... }
Java public static long factorial(long n) { }

In Pascal, the return value is specified by assigning the value to the function name:

   factorial := 1;

In C++ and Java, the return value is specified by a return statement:

   return (1);

Contents    Page-10    Prev    Next    Page+10    Index