8- programmer-defined functions, local and global variables, call-by-value Flashcards

1
Q

Function

A

named group of statements carrying out a particular task
to carry out its task the function accepts arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Predefined function

A

provided in libraries for the benefit of all programmers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Programmer-defined function

A

written by programmer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Caller

A

function that invokes another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Callee

A

function that is being invoked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Function definition

A

specifies instructions that the function executes
consists of head, body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Function prototype

A

declares (quickly introduces) the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Expanded form

A

mentions parameter types and names: names are optional but sometimes desirable for clarity
int add1(int i);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Abbreviated form

A

mentions only parameter types
int add1(int);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Local variable

A

variable that is declared inside a function is local (to that function): it cannot be used outside of the function
the scope of such variable is from declaration till end of function
parameters are also local variables
local variables of two different functions are different even if they have the same name
variables declared in main() are local to main()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Global constant

A

a constant declared outside any function definition
it can be used (its scope is) anywhere in the program from the place it is declared

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Global variable

A

variable declared outside any function definition
int errorcode = 0;
global variable scope is any function of the program from variable declaration down, functions can read and update global variable
using global variables introduces side effects to functions
what’s “side effect” gain?
makes program hard to understand: avoid!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly