CSI-130 Quiz 6

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

Given the following function: void calc (int a, int& b) { int c; c = a + 2; a = a * 3; b = c + a; } int x = 1; int y = 2; int z = 3; calc(x, y); cout << x << " " << y << " " << z << endl;

1 6 3

Given the following function code display? #include <iostream> 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; }

2 0 0

In the following function prototype, how many parameter variables does this function have? int myFunction(double, double, double);

3

What will the following code display? #include <iostream> 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; }

4 2

What will the following code display? # include <iostream> using namespace std; int getValue(int); int main( ) { int x = 2; cout << getValue(x) << endl; return 0; } int getValue(int num) { return num + 5; }

7

A function's return data type must be the same as the function's parameters (T/F)

FALSE

A local variable and a global variable may not have the same name within a program. (T/F)

FALSE

When a function is called, the flow of control moves to the function prototype (T/F)

FALSE

When a function is called, the flow of control moves to the function's prototype (T/F)

FALSE

You must always furnish an argument with a function call (T/F)

FALSE

a function's return data type must be the same as the function's parameters (T/F)

FALSE

Local variables are intialized to zero by default (T/F)

FALSE

Which of the following causes a function to execute?

a function call

These types of arguments are passed to parameters automatically if no argument is provided in the function call

default

A _____ function is declared outside all functions.

global

If a function is called more than once in a program, the values stored in the fnction's local variables do NOT _____ between function calls.

persist

_____ functions may have the same as long as their parameter lists are different.

two or more

A(n) _____ is information that is passed to a function, and a(n) _____ is information that is received by a function.

argument, parameter

Functions are ideal for menu-driven programs. When the user selects a menu item, the program can _____ the appropriate function

call

A function is executed when it is

called

Given the following header for a function named computeValue, which of the following is a valid call to the function? void computeValue (int Value)

computeValue(10);

A collection of statements that performs a specific task is a(n)

decision

A _____ argument is passed to a parameter when the actual argument is left out of the function

default

A function ______ contains the statements that make up the function.

definition

It is good programming practice to _____ your function by writing comments that describe what they do.

document

What is the data type of the following function prototype's parameter variable? int myFunction (double);

double

If a function does NOT have a prototype, default arguments may be specified in the _____.

function header

What is the data type of the following function prototype's return value? int myFunction(double);

int

Which line in the following program contains the prototype showDub function? 1 #include <iostream> 2 using namespace std; 3 void showDub(int); 4 int main() 5 {8 int x = 2; 6 showDub(x); 7 cout << x << endl; 8 return 0; 9 } 10 void showDub(int num) 11 { 12 cout << (num * 2) << endl; 13 }

line 3

Which line in the following program contains a call to the showDub function? 1 #include <iostream> 2 using namespace std; 3 void showDub(int); 4 int main() 5 { 6 int x = 2; 7 showDub(x); 8 cout << x << endl; 9 return 0; 10 } 11 void showDub(int num) 12 { 13 cout << (num * 2) << endl; 14 }

line 7

This type of variable is defined inside a function and is NOT accessible outside the function

local

A function can have no parameters, one parameter, or many parameters and can return _____ value(s)

only one

A function _____ eliminates the need to place a function definition before all calls to the function

prototype

When used as parameters, these types of variables allow a function to access the parameter's original argument:

reference

This statement causes a function to end

return

The value in this type of variable persists between function calls

static

The value in a _____ variable persists between function calls.

static local

A parameter is a special purpose variable that is declared inside the parentheses of a function definition (T/F)

TRUE

A static variable that is defined within a function is initialized only once, the first time it is called. (T/F)

TRUE

Global variables are intialized to zero by default (T/F)

TRUE

Global variables are intialized to zero by default. (T/F)

TRUE

It is not considered good programming practice to declare all your variables globally (T/F)

TRUE

It is possible for a function to have some parameters with default arguments and some without (T/F)

TRUE

One reason for using functions is to break programs into manageable units or modules (T/F)

TRUE

One reason for using functions is to break programs into manageable units or modules. (T/F)

TRUE


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

Ch. 5 Testbank, Hard disk Anatomy

View Set

AP Biology Practice Multiple Choice

View Set

XCEL: Chapter Exam (Health Provisions)

View Set