digital said:
What is the difference between function and procedure for C/C++ and Pascal.
Procedures are only possible in *imperative* computer programming
languages like Fortran, Pascal, C, C++, etc.
The *thread* of execution normally *proceeds* from one imperative
(executable statement) to the next. Flow control "structures"
such as conditionals, loops, switch, case, etc.
may change the normal sequence of execution.
Within the context of each imperative computer programming language,
procedures which return a value are called functions:
language returns value no return value
-----------------------------------------------
C/C++ function void function
Fortran function subroutine
Pascal function procedure
Note that functions need not be procedures:
int min(int i, int j) {
return (i < j)? i: j;
}
and simply return the value of an expression.
It is possible to write useful C programs
without any imperatives at all -- no procedures!
An *applicative* of "functional" programming language
like lisp has no imperatives and, thus, *no* procedures.