What is a procedure in programming?
A procedure is a named block of code that performs a specific task. It does not return a value.
What is a function in programming?
A function is a named block of code that performs a specific task and returns a value.
What is the main difference between a procedure and a function?
A function returns a value, while a procedure does not.
What is a parameter?
A parameter is a value that is passed into a procedure or function when it is called, allowing it to work with different data.
What is a return value?
A return value is the value that a function sends back to the part of the program that called it.
What does it mean to 'call' a procedure or function?
Calling a procedure or function means executing the code inside it at a specific point in the program.
Why are procedures and functions useful?
They allow you to break a large problem into smaller, manageable chunks, making code easier to write, read, test, and reuse.
What is modular programming?
Modular programming is the practice of dividing a program into separate, independent modules (procedures and functions) that each handle a specific task.
What is a subroutine?
A subroutine is another name for a procedure or function, a callable unit of code that performs a specific task.
What is a method?
A method is a procedure or function that is associated with an object or class in object-oriented programming.
What is a callable unit?
A callable unit is a general term for any named block of code (procedure, function, method, etc.) that can be invoked multiple times.
What is the purpose of giving a procedure or function a meaningful name?
A meaningful name makes the code easier to understand and maintain, as it describes what the code does.
How does modularity improve code quality?
Modularity reduces complexity, makes code easier to test and debug, and increases reliability and maintainability.
What is a return address?
A return address is the memory location where a program should continue executing after a subroutine finishes.
What is a stack in the context of subroutines?
A stack is a data structure used to store return addresses and local variables for nested subroutine calls.
What does 'recursive' mean in programming?
A recursive subroutine is one that calls itself, either directly or indirectly.
What is a call sequence?
A call sequence is a series of instructions used to call a subroutine in early computers that lacked a single subroutine call instruction.
Who is credited with the formal invention of the subroutine concept?
Maurice Wilkes, David Wheeler, and Stanley Gill are credited with the formal invention of the closed subroutine.
What is an open subroutine or macro?
An open subroutine (or macro) is code that is inserted directly at each call site, rather than being called as a separate unit.
What is the difference between a closed subroutine and an open subroutine?
A closed subroutine is a separate block of code that is called, while an open subroutine (macro) is copied into the program at each use.
What is the purpose of a return value in a function?
A return value allows a function to send a result back to the caller, which can then be used in further calculations.
Can a procedure have parameters?
Yes, a procedure can have parameters, but it does not return a value.
What is the benefit of using parameters in procedures and functions?
Parameters allow the same code to be reused with different inputs, making it more flexible and reducing duplication.
What is the difference between a function and a procedure in languages like COBOL and BASIC?
In these languages, a function returns a value, while a procedure (or subroutine) does not.