In programming, a is a sequence of steps or instructions that accomplishes a specific task. Procedures often operate on data, which can be passed as a , allowing flexibility and reusability. A parameter is a variable that is used to receive values from outside the procedure. It serves as a placeholder for the data that will be passed into the procedure.
The procedure can then process the data and perform computations, eventually producing a result known as the . This return value can be assigned to a within the procedure for further use or sent back to the ing part of the program.
Local variables are variables that are declared and used within a specific , such as inside a or a specific block of code. These variables are only accessible within their defined scope and are typically used to store temporary data needed for computations.
On the other hand, s are variables that are declared outside of any specific function or block, making them accessible throughout the entire program. Global variables can be accessed and modified by any function or block within the program, providing a way to share data across different parts of the code.
is a programming concept where a function calls itself, allowing the solution to a problem to be expressed concisely. When a function calls another function, it passes s to the called function. These arguments supply the necessary data for the called function to perform its task properly.
The action of invoking a function is known as a function call. It transfers control from the calling function to the called function, and typically, the called function returns a value back to the calling function after its completion. This process of allows a program to be divided into smaller, manageable pieces or functions, improving code organization and readability.
Functions have their own scope, known as . Variables declared within a function are only accessible within that function. On the other hand, refers to the scope of variables declared within a specific block of code, such as within a loop or conditional statement. These variables are only accessible within the block where they are declared.
Keywords
argument | scope | function scope | global variable | procedure | function | return value | local variable | parameter | block scope | modularization | recursion | call |