W8 - FUNCTIONS, ARRAYS, AND STRUCTS Flashcards

1
Q

W8-1: What is SCOPE?

A

_ The SCOPE of a program identifier determines its visibility.
_ Its scope depends on where we have placed its DEFINITION
_ A program variable may have: global scope, function scope, local scope, block scope

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

W8-2: What is a PROTOTYPE?

A

_ A function prototype identifies a function TYPE
_ provides the INFO that the compiler requires to validate a function CALL
_ is similar to the function HEADER

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

W8-3: What is #include?

A

_ define a function used by our host application in a file separate from the SOURCE file of our application.
=> store its prototype in a separate file: a HEADER file
_ HEADER file has the extension .h
_ insert the contents of the HEADER file into the source file of our application using a #include directive

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

W8-4: What is stdio.h?

A

_ The HEADER file that contains the PROTOYPES for the printf() and scanf() functions
_ is stored in a system directory

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

W8-5: What is GLOBAL SCOPE?

A

_ A variable declared OUTSIDE all function definitions has global scope
=> call such a variable a global variable.
_ Any program instruction can access a global variable
_ Global variables introduce a HIGH degree of COUPLING

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

W8-6: What is FUNCTION SCOPE?

A

_ A variable that is declared within a function header has function scope.
=> call such variables function parameters.
_ The scope of the parameter extends from the function HEADER to the CLOSING BRACE of the function BODY
=> the parameter goes out of scope at this closing brace

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

W8-7: What is LOCAL SCOPE?

A

A variable that is declared within a function BODY has local scope
=> call such variables local variables.
_ The scope of the variable extends from its DEFINITION to the END of the code block within which we declared the variable.
=> the variable goes OUT of scope at the CLOSING brace of its code block.

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

W8-8: What is BLOCK SCOPE?

A

_ A variable that is declared within a code block has block scope.
_ The scope of the variable extends from its DEFINITION to the END of the code block within which we declared the variable.
=> the variable goes OUT of scope at the CLOSING brace of its code block.

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