CSCI 240 Exam 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

What will be displayed by the following code? int main() { int num[5] = { 2, 4, 6, 8, 10 }; int i; fn(num); for( i = 0; i < 5; i++ ) cout << num[i] << ' '; return 0; } int fn( int n[] ) { n[3] = n[3] + 1; }

2 4 6 9 10

A variable called score is declared in main(). main() calls a function UpdateScore to update the score. UpdateScore also has a variable called score. When a value is added to score in UpdateScore, the value of score in main() is also changed. True/False?

False

The following is a valid array definition. int ar[]; True/False?

False

The function header and the calling statement must contain the name and the data type of the arguments. True/False?

False

Prototype statements are placed before int main().

True

The statement int main() means that main is a function that takes no arguments, and returns an integer. True/False?

True

the function name, return type, argument types, and argument names

Which of the following appear in a function header?

What is the subscript of the last element in the array Table if it is defined as follows? float Table[30];

a. 30 b. 31 c. 29 d. 0 e. none of the above Answer: c (29)

What will be displayed by the following code? int main() { int num = 3; fn(num); cout << num; return 0; } int fn( int n ) { n++; }

a. The code will not display anything b. 3 c. 4 d. 5 e. There is not enough information provided to determine what will be displayed. Answer: b (3)

Which of the following statements (a-d) about Table is true? float Table[] = { 0.9, 0.8, 0.7, 0.6 };

a. The definition for Table will cause an error because there is no value specified inside of the square brackets b. Table[1] contains the value 0.9 c. There are actually 5 values stored in Table - the four listed and a null terminator as the fifth element d. The definition for Table will cause an error because an array cannot be initialized when it is created e. All of the statement (a-d) are false Answer: e

We call the pieces of information that are passed to a function, which it then uses to do its task a/an ___________.

argument

A function prototype does not have to __________

include argument names

A function calling statement must supply arguments that:

match the function header in number, order, and data type

Complete the following sentence: the unsubscripted name of an array is _______________________________.

the address of the array.

When the body of a function begins to execute what is true of its arguments?

they already have values provided by the calling function and are ready to be used

If a function does not return anything, then the return type on the function prototype and function header is _____________.

void

A function may return __________ or __________ result(s). It may take __________ to __________ arguments.

0 or 1 result(s). 0 to many arguments.

Complete the following sentence: If you declare an array to hold N values, legal subscripts run from

0 to N - 1.

List two differences between a function prototype and a function header: ___________________________________________________________ ___________________________________________________________

- function prototype requires a semi-colon - function header requires argument names

Function prototypes are located ________________________________.

before int main()

How does a function report its answer back to its calling (or boss) function?

by executing a return statement with the answer


Conjuntos de estudio relacionados

CHAPTER 1: MENTAL HEALTH AND MENTAL ILLNESSES

View Set

PNU 120 Taylor PrepU Chapter 40: Fluid, Electrolyte. and Acid-Base Balance

View Set

MKT 300 Concept Check CH.4 (Hapke)

View Set

Pharmacology practice assessment b

View Set

Foundations and Practice of Mental Health Nursing HESI EXIT 5

View Set

server 2008 infrastructure chp 5

View Set