Chapter 6 C++

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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 2

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; return0; } void showDub(int num) { cout << (num * 2) << endl; }

4 2

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

EXIT_FAILURE and ________ are named constants that may be used to indicate success or failure when the exit( ) function is called.

EXIT_SUCCESS

________ functions may have the same name, as long as their parameter lists are different.

Two or more

In a function header, you must furnish: 1) data types of the parameters 2) the name of function 3) names of parameter variables 4) data type of the return value 5) all of these

all of these

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

argument, parameter

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

definition

It is a good programming practice to ________ your functions by writing comments that describe what they do.

document

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

double

This function causes a program to terminate, regardless of which function or control mechanism is executing.

exit( )

This is a statement that causes a function to execute.

function call

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

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

prototype

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

static local

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

default

A function can have zero to many parameters, and it can return this many values.

only one

Given the following function definition coid calc (int a, in& 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 types int) x=1; y =2; z=3; calc (x,y); cout << x<< " " << y << " " << z << endl;

1 6 3

Look at the following function prototype. int myFunction (double, double, double); How many parameter variables does this function have?

3

Which of the following statements about global variables is true?

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

A(n) ________ argument is passed to a parameter when the actual argument is left out of the function call.

default

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

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

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

A function is executed when it is:

called


Set pelajaran terkait

PREP-U Chapter 19: (COMBINED) Assessing Thorax and Lungs

View Set

Intro to Rhetorical Theory Final

View Set

2.2.4 Quiz: Trouble in the Colonies Apex

View Set

NUT 150 Nutrient Absorption and Delivery 4.4

View Set

CS Chapter 6: Malicious Software

View Set

ATI: Fluid, Electrolyte, and Acid-Base Regulation

View Set

Collecting Subjective Data (Coursepoint)

View Set