Hogan Chapter 6

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Given the following function definition void calc (int a, int& b) { int c; c = a + 2; a = a * 3; b = c + a; } What is the output of the following code fragment that invokes calc? (All variables are of type int) x = 1; y = 2; z = 3; calc(x, y); cout << x << " " << y << " " << z << endl; 1 2 3 1 6 3 3 6 3 1 14 9

1 6 3

In a function header, you must furnish data type(s) of the parameters data type of the return value the name of the function names of parameter variables All of these

All of these

These types of arguments are passed to parameters automatically if no argument is provided in the function call. Local Default Global Relational

Default

A function's return data type must be the same as the function parameter(s) data type(s). True False

False

A local variable and a global variable may not have the same name within the same program. True False

False

Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function. call prototype define declare

call

A function is executed when it is defined prototyped declared called

called

Here is the header for a function named computeValue: void computeValue(int value) Which of the following is a valid call to the function? computeValue(10) computeValue(10); void computeValue(10); void computeValue(int x);

computeValue(10);

What is the output of the following program? #include using namespace std; void doSomething(int&); int main() { int x = 2; cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int& num) { num = 0; cout << num << endl; } a. 2 0 2 b. 2 2 2 c. 0 0 0 d. 2 0 0

d

A function __________ contains the statements that make up the function. definition prototype call expression parameter list

definition

This function causes a program to terminate, regardless of which function or control mechanism is executing. terminate() return() continue() exit()

exit()

This is a collection of statements that performs a specific task. infinite loop variable constant function

function

This is a statement that causes a function to execute. for loop do-while loop function prototype function call

function call

Look at the following function prototype int myFunction(double); What is the data type of the function's return value? int double void Can't tell from prototype

int

This type of variable is defined inside a function and is not accessible outside the function. global reference local counter

local

If a function is called more than once in a program, the values stored in the function's local variables do not _________ between function calls. persist execute communicate change

persist

When used as parameters, these types of variables allow a function to access the parameter's original argument. reference floating-point counter undeclared

reference

This statement causes a function to end. end terminate return release

return

The value in this type of local variable persists between function calls. global internal static dynamic

static

Which of the following statements about global variables is true? A global variable is accessible only to the main function. A global variable is declared in the highest-level block in which it is used. A global variable can have the same name as a variable that is declared locally within a function. If a function contains a local variable with the same name as a global variable, the global variable's name takes precedence within the function. All of these are true

A global variable can have the same name as a variable that is declared locally within a function.

When a function is called, flow of control moves to the function's prototype. True False

False

You must furnish an argument with a function call. True False

False

A parameter is a special-purpose variable that is declared inside the parentheses of a function definition. True False

True

A static variable that is defined within a function is initialized only once, the first time the function is called. True False

True

Numeric global variables are initialized to zero by default. True False

True

_________ functions may have the same name, as long as their parameter lists are different. Only two Two or more Zero Un-prototyped

Two or more

What is the output of the following program? #include using namespace std; void doSomething(int); int main() { int x = 2; cout << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int num) { num = 0; cout << num << endl; } a. 2 0 2 b. 2 2 2 c. 0 0 0 d. 2 0 0

a

A(n) _________ is information that is passed to a function, and a(n) _________ is information that is received by a function. function call, function header parameter, argument argument, parameter prototype, header

argument, parameter

What is the output of the following program? #include using namespace std; void showDub(int); int main() { int x = 2; showDub(x); cout << x << endl; return 0; } void showDub(int num) { cout << (num * 2) << endl; } a. 2 2 b. 4 2 c 2 4 d. 4 4

b

This is a dummy function that is called instead of the actual function it represents. main function stub driver overloaded function

stub


संबंधित स्टडी सेट्स

Головні та другорядні члени речення

View Set

PSY 4570: Cognitive Psychology Quiz 1

View Set

Chapter 13: Current Liabilities and Contigencies

View Set

CompTIA A+ Core 2 - Practice Exam One

View Set

Chapter 2 Introduction to Systems Architectures

View Set

SY0-601 14 Summarizing Secure Application Concepts

View Set