C++ 6.2-6.3

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

not a valid prototype for a function that has one parameter that is a reference variable

void calculate(int);

If you want to define a function called displaySum that has three int parameters, x, y, and z, which of the following function headers would be correct?

void displaySum(int x, int y, int z)

a parameter variable and the original argument variable have the same storage location in memory.

False statement

Unless global variables are explicitly initialized, they are automatically initialized to

0

A _______ variable is defined outside all functions and is accessible to all functions in its scope.

global

A value-returning function returns a value of a specific data type.

True statement

The return statement causes a function to end immediately.

True statement

the scope of a function's parameter is limited to the body of the function that uses it

True statement

The return statement is used in a function to return a value back to the part of the program that called the function. The general format of the return statement is: return expression;, where expression is

a literal value, • a variable , a mathematical expression

A global variable is accessible by all functions that are defined _____ the global variable is defined.

after

contains one global variable. It is defined ______ the main function.

before

If we want to write a function named found that returned a bool and has one int parameter named index and one double parameter named value, which function header would be correct?

bool found(int index, double value)

For a function that has a parameter that is passed by reference (reference variable), the ampersand does not appear in the

function call

A function's parameter variables can be used to _______ local variables.

initialize

Which of the following is the correct prototype statement for the function shown below? int sum(int number1, int number2) { return (number1 + number2); }

int sum(int, int);

when the variable num is changed to 50 in the function anotherFunction, its value

is also changed to 50 in the main function

A function's local variables exist only while the function is executing. This is known as the ________ of a local variable.

lifetime

A _______ variable is defined inside a function and is not accessible outside the function.

local

Assume that num1, num2, and num3 are int variables whose values are assigned in the main function as follows: num1 = 5, num2 = 10, num3 = 3. If the function sum, which is shown below, is called from the main function with the statement sum(num1, num2, num3);, what will be the values of num1, num2, and num3 after function sum runs and control returns back to the main function? void sum(int num1, int num2, int &num3) { num1 = 4; num2 = 8; num3 = num1 + num2; }

num1 = 5, num2 = 10, num3 = 12

A global variable is any variable defined

outside all the functions in a program

When used as a function parameter, a _________ allows a function to change the value of the original argument.

reference variable

Which statement is false about global constants?

their use can cause the same problems associated with the use of global variables

statement is false about global constants

their use can cause the same problems associated with the use of global variables

Which statement is false about global variables?

they can make debugging easier

statement is false about global variables

they can make debugging easier

the only arguments that can be passed to a function by reference

variables


Conjuntos de estudio relacionados

English Much Ado About Nothing Test

View Set

MI Real Estate: Calculations TEST

View Set

CH 24: Conditions in the Newborn Related to Gestation Age, Size, Injury, and Pain

View Set

Motivation-Chapter 12- AP Psychology

View Set

Technologies and Tools Practice Test

View Set