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

1. The programmer should always use a defined constant in an array declaration.

2. 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. True
Explanation: 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.
2. False
Explanation: 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...

You can help keep your system safe by keeping your browser and operating system updated

Indicate whether the statement is true or false

Computer Science & Information Technology

In a(n) ______ relationship, a class object has one or more objects of other classes as members.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

What questions should be answers to assess usability of a mobile device?

What will be an ideal response?

Computer Science & Information Technology

NetStumbler can capture and decode wireless packets, monitor utilization, or make automatic connections to networks it discovers.

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

Computer Science & Information Technology