CS-2250: Starting out with C++: Chapter 6 Quiz

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

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

Definition

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

E) All of these

This is a collection of statements that performs a specific task.

Function

A ________ variable is declared outside all functions

Global

If a function does not have a prototype, default arguments may be specified in the function ________.

Header

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

False

Local variables are initialized to zero by default.

False

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

False

You must furnish an argument with a function call.

False

It is not considered good programming practice to declare all of your variables globally.

True

The value in this type of local variable persists between function calls.

static

The value in a(n) ________ variable persists between function calls

static local

Which line in the following program contains a call to the showDub function? 1 #include<iostream> 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 }

10 showDub(x);

What is the output of the following program? #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

What is the output of the following program? #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

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

Call

One reason for using functions is to break programs into manageable units, or modules.

True

You may use the exit( ) function to terminate a program, regardless of which control mechanism is executing.

True

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

default

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

double


Conjuntos de estudio relacionados

AP US History Flash Cards Set #1

View Set

DP1 2022 Case Study Important Key Terms

View Set

Microbio - Ch. 11 review questions

View Set

Survey of Math - Section 5.1: Number Theory

View Set