◆ A portion of code within a larger program. Often called …
◆ A portion of code within a larger program. Often called
a subroutine or procedure in imperative languages like C
methods in OO languages like Java
and functions in functional languages like Haskell
◆ Functions return a value. So some purists would say that a C
function returning void is actually a procedure !
◆ Procedures are necessary for:
reducing duplication of code and enabling re-use
decomposing complex programs into manageable parts
◆ Procedures can call each other and can even call themselves
◆ What happens when we call a procedure?
The caller is suspended; control hands over to the callee
Callee performs the requested task
Callee returns control to the caller