Answer the following statements true (T) or false (F)

1. If we want to find the median of 100 scores, we need 100 separate variables to hold
the data..
2. An array behaves like a list of variables each of which is of the same type and for
which there is a uniform, convenient naming convention that can be declared in a
single line of code. In the explanation, give an example of declaration and access.
3. With arrays, indices start at any number the programmer chooses to indicate in the
definition.
4. The programmer should always use a defined constant in an array declaration.
5. When using an array, it is perfectly legal to access indexed variables with index
values less than 0 or greater than or equal to the declared size of the array.


1. False
We can (much more easily) use an array of 100 of the type of the scores
to find the median.
2. True.
For example, an array of 400 double values is declared
double array[400];
Access for read or write is array[index], where 0<=index<400.
3. False
Index values start at 0, not any other number, and run to one less than
the declared size.
4. True
The reason is flexibility. A program with an array with declared size of
5 only works with a maximum of 5 of whatever the array holds. If things change so
that we need to process 17 of these things, we are faced with the difficult and error
prone task of finding all places in the program that 5 is used as an array size,
including situations where someone has done arithmetic with the 5 and some other
number. Better to use a defined constant from the start.
5. False
These index values are out of range, or simply illegal. The compiler
cannot catch this. Unless you access protected memory doing this, the C++ runtime
system will not catch this mistake either. The programmer has the obligation of
detecting illegal index values or assuring there will be none.

Computer Science & Information Technology

You might also like to view...

Intermediate operations are________; they aren’t performed until a terminal operation is invoked. This allows library developers to optimize stream-processing performance.

a. eager b. idle c. lazy d. inactive

Computer Science & Information Technology

What is distributed computing?

What will be an ideal response?

Computer Science & Information Technology

Dragging a round sizing handle alters the shape of a placeholder or other selected object.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

How do you enter static IP information in Windows and in macOS?

What will be an ideal response?

Computer Science & Information Technology