COSC-1337 Chapter 6 Flashcards
What is the approach of using functions in a program known as?
Divide and conquer.
What is the benefit of using functions in your program?
Code reuse. You can reuse the same functions throughout the entire program without having to rewrite them over and over.
What is a “function call”?
It is a statement that causes a function to execute.
What is the first line of a function called?
Function header
Just like header files in our program, what do we need for function to be included in our program as well?
Function prototypes. These come before the main function begins.
Values that are sent to a function are called?:
Arguments
The “return” statement will cause a function to do what?
End immediately.
A function that returns a value is known as a?
Value-returning function
Variables that are defined inside of a function are known as?
Local variables
A local variable can only be accessed from?
Within the function that created it
A global variable can be accessed from?
Anywhere in the program
What happens to local variables after their function’s end?
The “lifetime” of the local variable is destroyed.
Where do you have to declare a variable for it to be “global”?
Outside of all functions INCLUDING MAIN
How would you clear the screen?
system(“clear”);
What happens if the name of a Global Variable/Constant is the same as a local variable in a function?
The global variable is “shadowed” by the local variable in the function.
This means that the global variable is not seen by the local variable in the function with the same name.