Cosc 6-7

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

What will the following code display? int numbers[4] = { 99, 87 }; cout << numbers[3] << endl;

0

How many elements does the following array have int bugs[1000];

1000

Which line in the following program contains the header 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 court << x << endl; 12 return 0; 13 } 14 15 void showDub (int num) 16 { 17 cout << (num * 2) << endl; 18 }

15

What will the following C++ 11 code display vector<int> numbers { 3, 5 } for (int val : numbers)

3 5

What is the last legal subscript that can be used with the following array? int values[5];

4

Which line in the following program contains the prototype for this 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 sho wDub(x); 11 court << x << endl; 12 return 0; 13 } 14 15 void showDub (int num) 16 { 17 cout << (num * 2) << endl; 18 }

4

What is the output of the following program 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 court << x << endl; 12 return 0; 13 } 14 15 void showDub (int num) 16 { 17 cout << (num * 2) << endl; 18 }

4 2

What will the following code display? Int numbers[ ] = { 99, 87, 66, 55, 101 } for (int i = 1; i < 4; i++) cout << numbers[ i ] << endl;

87 66 55

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 two-dimensional array of characters can contain A) strings of the same length B) strings of different lengths C) uninitialized elements D) All of these E) None of these

All of these

What will the following code do const int SIZE = 5; double x[SIZE]; for (int i = 2; i <= SIZE; i++) { x[i] = 0.0; }

An error will occur when the code runs

Unlike regular variables, these can hold multiple values.

Arrays

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

Default

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

Document

Enough 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 parameters variables E) All of these

E) All of these

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

EXIT_SUCCESS

True/False: Although two-dimensional arrays are a novel idea, there is no known way to pass one to a function.

False

True/False: Assume array1 and array2 are the names of arrays. To assign the contents of array2 to array1, you would use the following statement. array1 = array2;

False

True/False: C++ limits the number of array dimensions to two.

False

True/False: The statement double money[25.00]; Is a valid C++ array definition

False

True/false: A function's return data type must be the same as the function's parameter(s)

False

True/false: An array initialization list must be placed on one single line

False

True/false: In C++ 11, the range-based for a loop is best used in situations where you need the element subscript for some purpose

False

True/false: When a function is called, flow of control moves to the functions prototype

False

True/false: local variables are initialized to zero by default

False

This is a statement that causes a function to execute

Function call

What does the following statement do vector<int> v(10, 2);

It creates a vector object with a starting size of 10 and all elements are initialized with the value 2.

What does the following statement do vector<int> v(10);

It creates a vector object with a starting size of 10.

It is ______ to pass an argument to a function that contains a individual array element, such as numbers [3]

Legal in C++

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

Local

If a function is called more than once in a program, the values stored in the functions local variables do not _____ between function calls

Persist

This statement causes a function to end

Return

This is a dummy function that is called instead of the actual function it represents

Stub

A vector object automatically expands inside to accommodate the items stored in it

True

True/false: A static variable that is defined within a function is initialized only once, the first time the function is called

True

True/false: If an array is partially initialized, the uninitialized elements will be set to zero

True

True/false: In C++ 11, you cannot use a range-based for loop to modify the contents of an array unless you declare the range variable as a reference

True

True/false: The amount of memory used by an array depends upon the arrays day at a time and the number of elements in the array

True

True/false: When you pass an array as an argument to a function, the function can modify the contents of the array

True

True/false: it is possible for a function to have some parameters with default arguments and some without

True

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

Two or more

To assign the contents of one array to another, you must use _______

a loop to assign the elements of one array to the other array

When writing functions that accept multi-dimensional arrays as arguments, ______ must be explicitly stated in the parameter list

all but the first dimension

A(n) _______ is information that is passed to a function, and a(n) ______ is information that is received by a function

argument, parameter

An array's size declarator must be a ________ with a value greater than ________.

constant integer expression, zero

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

default

The individual values contained in array are known as ______

elements

This vector function returns true if the vector has no elements

empty

An array can easily be stepped through by using a

for loop

This is a collection of statements that performs a specific task

function

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

header

An array with no elements is

illegal in C++

The statement: int grades[ ] = { 100, 90, 99, 80}; Shows an example of:

implicit array sizing

Which of the following is a valid C++ array definition

int array[10];

Which of the following is a valid C++ array definition

int scores [10];

The name of an array stores the ______ of the first array element

memory address

To pass an array as a argument to a function, pass the ______ of the array

name

The _____ is automatically appended to a character array when it is initialized with a string constant

null terminator

A two-dimensional array can have elements of ______ data type(s)

one

This vector function removes an item from a vector

pop_back

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

prototype

This vector function is used to insert an item into a vector

push_back

The range-based for loop, in C++ 11, is designed to work with a built-in variable known as the _______

range variable

A two-dimensional array can be viewed as _____ and ________

rows, columns

Given the following declaration, where is the value 77 stored in the scores array

scores[2]

A two-dimensional array is like _______ put together

several identical arrays

The vector function returns the number of elements in a vector

size

The value in a ______ variable persists between function calls

static local

An array of string objects that will hold 5 names would be declared using which statement?

string names[5];

By using the same _____ you can build relationships between data stored in two or more arrays

subscript

To access an array element, use the array name and the element's ______

subscript

An element of a two-dimensional array is referred to by ________ followed by ________.

the row subscript of the element, the column subscript of the element

Which statement correctly uses C++ 11 to initialize a vector of ints named n with the values 10 and 20

vector<int> n { 10, 20 };

Which statement correctly defines a vector object for holding integers

vector<int> v;

If you leave out the size declarator in an array definition:

you must furnish an initialization list


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

Principles of Marketing test 3 (warm ups)

View Set

Texas LT care and partnership policies

View Set

NUR 423 Exam 2 Book/quiz question practice

View Set

Chapter 24-The Fetal Head and Brain

View Set

CH 14: Nutrition during pregnancy & breastfeeding

View Set

Quiz: Module 11 Wireless Network Security

View Set

Music History Middle Ages and Renaissance

View Set

Kaplan Pediatrics Review Questions

View Set

Chapter 16-28 - give me liberty all study questions/chronological for Final

View Set