Home
71.
What happens if I use a subscript on an array that is larger than the number of elements in the array?

If you use a subscript that is out of bounds with the array declaration, the program will probably compile and even run. However, the results of such a mistake can be unpredictable. This can be a difficult error to find once it starts causing problems, so make sure you’re careful when initializing and accessing array elements

72.
How many dimensions can an array have?

As stated in today’s lesson, you can have as many dimensions as you want. As you add more dimensions, you use more data storage space. You should declare an array only as large as you need to avoid wasting storage space.

73.
Is there an easy way to initialize an entire array at once?

Each element of an array must be initialized. The safest way for a beginning C programmer to initialize an array is either with a declaration, or with a for statement.

74.
Can I add two arrays together (or multiply, divide, or subtract them)?

If you declare two arrays, you can’t add the two together. Each element must be added individually.

75.
What do you do if you don’t know how big the array needs to be when you’re writing the program?

There are functions within C that let you allocate space for variables and arrays onthe- fly.

76.
Which of C's data types can be used in an array?

All of them, but one at a time. A given array can contain only a single data type.

77.
If an array is declared with 10 elements, what is the subscript of the first element?

0. Regardless of the size of an array, all C arrays start with subscript 0.

78.
In a one-dimensional array declared with n elements, what is the subscript of the last element?

n-1

79.
What happens if your program tries to access an array element with an out-ofrange subscript?

The program compiles and runs, but it produces unpredictable results.

80.
How do you declare a multidimensional array?

In the declaration statement, follow the array name with one set of brackets for each dimension. Each set of brackets contains the number of elements in the corresponding dimension.