Functions Flashcards
What is a function in programming?
A module that returns a value back after performing a specific task.
Can the value returned by a function be used like other values?
Yes, it can be used like any other value.
What is a library function?
A function built into the programming language, usually found in the standard library.
What three things must you know about a library function?
Its purpose, the arguments to pass, and the data it returns.
What are you essentially creating when you write your own function?
A module.
What is the role of a function’s header?
It specifies the return value data type, the function name, and parameter variables.
What does the body of a function contain?
One or more statements that are executed after a function call.
What is the role of the return statement in a function?
It returns a value to the part of the program that called the function.
What is a parameter variable in a function header?
A variable that receives a value when the function is called.
Where is the first line of a function definition located?
In the function header.
What is used to represent the starting terminal of a function in a flowchart?
The function’s name and parameters.
Why are flowcharts helpful when designing functions?
They visually represent the sequence and parameters of the function.
What can a return statement return, aside from plain values?
Expressions.
Why is the ability to return expressions useful in a function?
It allows flexibility in computations before returning a result.
What does IPO stand for in IPO charts?
Input, Processing, and Output.
How does an IPO chart assist with function development?
It organizes the input, processing, and output components of a function.
What does the function’s return value depend on?
The return statement’s expression or value.
How can a function enhance modularity in programming?
By encapsulating specific tasks into reusable modules.
What is a key difference between library functions and custom-written functions?
Library functions are predefined, while custom-written functions are user-defined.
What is required to call a function?
Its name and the correct number/type of arguments (if any).