Filters
Question type

Study Flashcards

To step through a one-dimensional array, accessing the elements one by one, it would be most appropriate to use ________ loop.


A) an infinite
B) a sentinel controlled loop
C) a for loop
D) a nested loop
E) no

F) C) and D)
G) B) and D)

Correct Answer

verifed

verified

The size of an array is the number of elements that have data stored in them.

A) True
B) False

Correct Answer

verifed

verified

On each iteration of the following range-based for loop for (int element : myArray) Cout << element << endl; The variable element holds


A) an array value.
B) an array subscript.
C) an array name.
D) an array location.
E) none of the above.

F) A) and E)
G) B) and D)

Correct Answer

verifed

verified

A

The following statement for(int val : myArray) Cout << val << " "; Is an example of a(n)


A) regular for loop.
B) range-based for loop.
C) nested for loop.
D) infinite for loop.
E) illegal statement.

F) D) and E)
G) A) and B)

Correct Answer

verifed

verified

The amount of memory used by an array depends solely on the number of elements the array can hold.

A) True
B) False

Correct Answer

verifed

verified

False

When you pass an array as an argument to a function, the function can modify the contents of the array.

A) True
B) False

Correct Answer

verifed

verified

The elements of an array can be


A) strings.
B) structures.
C) objects.
D) any of the above.
E) none of the above.

F) A) and E)
G) A) and C)

Correct Answer

verifed

verified

The following array definition is legal because C++ allows arrays to be implicitly sized. int grades[ ];

A) True
B) False

Correct Answer

verifed

verified

After carrying out the following two statements, sales will have been created as a one-dimensional array that can hold 20 double values. typedef salesArray double[20]; salesArray sales;

A) True
B) False

Correct Answer

verifed

verified

True

If a C++ program contains the following array definition int score[10]; the following statement would store 100 in the first array element: score[1] = 100;

A) True
B) False

Correct Answer

verifed

verified

When you create a vector it is unnecessary to specify how many elements it will hold because it will expand in size as you add new values to it.

A) True
B) False

Correct Answer

verifed

verified

You can assign the contents of one array to another by using


A) the assignment operator.
B) the equality operator.
C) both array names.
D) A and C together.
E) none of the above.

F) A) and C)
G) D) and E)

Correct Answer

verifed

verified

An array can store multiple values, but the values must be


A) all the same data type.
B) declared at the time the array is created.
C) constants.
D) numeric, not characters or strings.
E) none of the above.

F) All of the above
G) C) and D)

Correct Answer

verifed

verified

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


A) name.
B) data type.
C) value.
D) subscript.
E) size declarator.

F) C) and D)
G) A) and B)

Correct Answer

verifed

verified

An array can be returned by a function as well as passed to a function.

A) True
B) False

Correct Answer

verifed

verified

Elements of vectors can be access by using the vector name and a subscript, similarly to how array elements are accessed.

A) True
B) False

Correct Answer

verifed

verified

Any of the following statements can be used to initialize the integer variable num to 7; int num = 7; int num(7); int num{7};

A) True
B) False

Correct Answer

verifed

verified

When an array is passed to a function, it is actually ________ the array that is passed.


A) the starting memory address of
B) a copy of all the values in
C) the value stored in the first element of
D) the data type and size of
E) the data type and name of

F) A) and D)
G) All of the above

Correct Answer

verifed

verified

Each individual element of an array can be accessed by the array name and an element number, called a subscript.

A) True
B) False

Correct Answer

verifed

verified

What does the following statement do? Typedef int oneDArray[20];


A) It creates an array of 20 integers.
B) It makes oneDArray a copy of another 20-integer array.
C) It makes oneDArray an alias for a data type that holds 20 integers.
D) It creates a one-dimensional integer array with all elements initialized to 20.
E) It does none of the above.

F) A) and D)
G) A) and C)

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer