Choosing Between a Function and a Procedure
In a simple calculator program, which module type should you use to compute and return the product of two numbers so it can be used inside another expression?
- Function
- Procedure
- Event handler
- Class
- Funtion
Parameters vs. Arguments
When calling a module greet('Ava') that was defined as a procedure greet(name), what is the correct term for the value 'Ava' supplied at call time?
- Argument
- Parameter
- Return value
- Local variable
- Parametre
Reuse and Maintenance via Modules
If a sales app puts its tax calculation in a single function computeTax(amount), what is the main benefit of this modular design for easy programs?
- It centralizes the logic so all code can reuse it and updates happen in one place.
- It guarantees the program will run twice as fast.
- It automatically encrypts all financial data.
- It eliminates the need for testing.
- It increases the number of global variables required.
Identifying a Pure Function
Which statement best describes a pure function in a module that squares a number, such as square(x) returning x*x?
- It returns the same result for the same input and does not change program state.
- It prints the result to the screen and updates a global counter.
- It may return different results for the same input if called at night.
- It stores the result in a file for later use.
- It requires pass-by-reference to work.
Local Variable Scope in Modules
Inside a function sum(a, b), a variable total is set to a + b but not returned; which statement about total is generally true in modular programs?
- It cannot be accessed directly from code outside the function.
- It becomes a global variable after the function finishes.
- It persists automatically across multiple runs of the program.
- It can be modified by callers even without being passed by reference.
- It is compiled into a public constant named TOTAL.