Arrays Flashcards
Declare an array named scores of twenty-five elements of type int .
int scores[25];
Describe what is an array
A collection of contiguous or adjacent memory cells associated with one variable name and one type
An array is considered a data structure
In C++, the array index begins at…
position 0
range of array index values
Index values must be between 0 and (array size -1)
How to initialize an array during declaration
Place the initializing values in braces. Example:
double sales[5] = {12,32,16,23,45};
To copy, read, or compare arrays, it must be done…
componentwise
2d ARRAYS
myarray[row][collums]
What are parallel arrays used for?
To hold related information.
How do you access an element of a two-dimensional array?
You need a pair of indices: one for the row position and one for the column position.
When declaring a two-dimensional array as a formal parameter, what can you omit?
The size of the first dimension but not the second.
What is the difference between a size declarator and a subscript?
The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element in an array.
C++ has no array _________ checking, which means you can inadvertently store data past the end of an array.
Bounds
reference the 10th position of the array my array
n=myarray[10]