FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

WHAT IS PROGRAMMING

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the difference between functions and procedures?
A
Function are sub-programs defined outside the main program. Whereas, procedures are defined inside the main program.
B
Functions return values but procedures do not return a value.
C
None of the above
D
None of the above
Explanation: 

Detailed explanation-1: -Whenever a function is called, it is first compiled before being called. A procedure is compiled once and can be called multiple times without being compiled. A function returns a value and control to calling function or code. A procedure returns the control but not any value to calling function or code.

Detailed explanation-2: -The function must return a value but in Stored Procedure it is optional. Even a procedure can return zero or n values. Functions can have only input parameters for it whereas Procedures can have input or output parameters. Functions can be called from Procedure whereas Procedures cannot be called from a Function.

Detailed explanation-3: -Functions can be called from SQL whereas procedures cannot be called. Function can be used in place of an expression whereas a procedure can’t be used so. Functions are used for executing business logic and computation but a procedure is not.

Detailed explanation-4: -If you specify the output keyword for a parameter in the procedure definition, the procedure can return the current value of the parameter to the calling program when the procedure exits.

Detailed explanation-5: -A procedure is a named PL/SQL block that carries out one or more actions. A function is a named PL/SQL block that returns a value. They’re close cousins and, based on those definitions, it may be difficult to tell them apart.

There is 1 question to complete.