Docsity

C++ Exam 2 Preparation, Exams of Nursing

Toggle sidebar
bg1
C++ Exam 2 rated A 2025
This is a collection of statements that performs a specific task.
A) infinite loop
B) variable
C) constant
D) function
E) None of these - Function.
A function ________ contains the statements that make up the function.
A) definition
B) prototype
C) call
D) expression
E) parameter list - Definition.
A function can have zero to many parameters, and it can return this many values.
A) zero to many
B) no
C) only one
D) a maximum of ten
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36

Partial preview of the text

Download C++ Exam 2 Preparation and more Exams Nursing in PDF only on Docsity!

This is a collection of statements that performs a specific task. A) infinite loop B) variable C) constant D) function E) None of these - Function. A function ________ contains the statements that make up the function. A) definition B) prototype C) call D) expression E) parameter list - Definition. A function can have zero to many parameters, and it can return this many values. A) zero to many B) no C) only one D) a maximum of ten

E) None of these - Only one. A function is executed when it is: A) defined B) prototyped C) declared D) called E) None of these - Called. In a function header, you must furnish: A) data type(s) of the parameters B) data type of the return value C) the name of function D) names of parameter variables E) All of these - Names of parameter variables. Functions are ideal for use in menu-driven programs. When a user selects a menu item, the program can ________ the appropriate function. A) call

These types of arguments are passed to parameters automatically if no argument is provided in the function call. A) Local B) Default C) Global D) Relational E) None of these - Default. When used as parameters, these types of variables allow a function to access the parameter's original argument. A) reference B) floating-point C) counter D) undeclared E) None of these - Reference. This statement causes a function to end. A) end B) terminate

C) return D) release E) None of these - return ________ functions may have the same name, as long as their parameter lists are different. A) Only two B) Two or more C) Zero D) Un-prototyped E) None of these - Two or more. This function causes a program to terminate, regardless of which function or control mechanism is executing. A) terminate() B) return() C) continue() D) exit() E) None of these - exit()

A) 1 2 3

B) 1 6 3

C) 3 6 3

D) 1 14 9

E) None of these - 1 14 9 This is a statement that causes a function to execute. A) for loop B) do-while loop C) function prototype D) function call E) None of these - Do-while loop. It is a good programming practice to ________ your functions by writing comments that describe what they do. A) execute B) document C) eliminate

D) prototype E) None of these - Document. A(n) ________ is information that is passed to a function, and a(n) ________ is information that is received by a function. A) function call, function header B) parameter, argument C) argument, parameter D) prototype, header E) None of these - Argument, parameter. Which of the following statements about global variables is true? A) A global variable is accessible only to the main function. B) A global variable is declared in the highest-level block in which it is used. C) A global variable can have the same name as a variable that is declared locally within a function. D) 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. E) All of these are true. - A global variable can have the same name as a variable that is declared locally within a function.

C) communicate D) change E) None of these - Persist. A ________ argument is passed to a parameter when the actual argument is left out of the function call. A) false B) true C) null D) default E) None of these - Default. If a function does not have a prototype, default arguments may be specified in the function ________. A) call B) header C) execution D) return type E) None of these - Header.

EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure when the exit() function is called. A) EXIT_TERMINATE B) EXIT_SUCCESS C) EXIT_OK D) RETURN_OK E) None of these - EXIT_SUCCESS The value in a ________ variable persists between function calls. A) dynamic B) local C) counter D) static local - Static local. This is a dummy function that is called instead of the actual function it represents. A) main function B) stub C) driver D) overloaded function - Stub.

cout << (num * 2) << endl; } A) 2 2 B) 4 2 C) 2 4 D) 4 4 - 4 2 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; }

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 - 2

15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 } A) 4 B) 6 C) 10 D) 15 - 4 Which line in the following program contains the header for the showDub function? 1 #include 2 using namespace std; 3 4 void showDub(int); 5

6 int main() 7 { 8 int x = 2; 9 10 showDub(x); 11 cout << x << endl; 12 return 0; 13 } 14 15 void showDub(int num) 16 { 17 cout << (num * 2) << endl; 18 } A) 4 B) 6 C) 10 D) 15 - 15