C++ Chapter 6 OCCC Fall 2019 Goulden

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 = num * 2;}

2 2

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

Header

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

True

Here is the prototype for a function named computeValue: void computeValue(int value); Which of the following is a valid call to that function? Select one: a. computeValue(10) b. void computeValue(10); c. computeValue(10); d. void computeValue(int x);

computeValue(10);

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? Select one: a. void b. int c. double d. can't tell from the prototype

double

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

exit( )

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

int

A function is executed when it is:

called

What is the output of the following program? #include <iostream>using namespace std;void showInts(int, int);void changeInts(int, int &);int main(){int first = 1, second = 2;showInts(first, second);changeInts(first, second);showInts(first, second);return 0;} void showInts(int first, int second){cout << first << " " << second << endl;}void changeInts(int aNumber, int & anotherNumber){int first = 3, second = 4;anotherNumber = second * anotherNumber;aNumber = first * aNumber;}

1 21 8

Arguments are passed to a function in the order in which they appear in the function call. Select one: True False

'True'.

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 = num * 2; }

2

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

document

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

local

#include <iostream>using namespace std;void showInts(int, int);void changeInts(int, int);int main(){int first = 1, second = 2;showInts(first, second);changeInts(first, second);showInts(first, second);return 0;} void showInts(int first, int second){cout << first << " " << second << endl;}void changeInts(int aNumber, int anotherNumber){int first = 3, second = 4;anotherNumber = second * anotherNumber;aNumber = first * aNumber;}

1 21 2

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; } Select one: a. 00 b. 02 c. 20 d. 22

2 2

Consider the function prototype "int myFunction (double, double, double, double);" How many parameters does this function have?

4

Which line in the following program contains (or begins) the prototype for 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 }

4

In a function header, you must furnish: Select one: a. the names of all of the parameters b. the name of function c. the data type of the return value d. the data types of the parameters e. All of these

All of these

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

False

In C++, parameters are passed to functions in three different ways. These three ways are:

Value, Pointer, Reference

A named collection of statements that performs a specific task is a Select one: a. infinite loop b. constant c. function d. variable e. prototype

function

What are the two parts of a function signature? Select one or more: a. parameter list b. function name c. return type .

function name, parameter list

A function ________ eliminates the need to place a function definition before all calls to the function. Select one: a. prototype Correct b. header c. argument d. parameter e. name

prototype

This statement causes a function to end. Select one: a. end b. release c. return d. terminate e. None of these

return


Set pelajaran terkait

AWS Academy Cloud Foundations - Modules 1 - 8

View Set

Unit 2- Med Surg: Cardiovascular

View Set

History & Geography 808: Twentieth Century World Power - Quiz 1: Overseas Expansion

View Set