- Home
- Interview Questions
- C Programming
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
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.
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.
If you declare two arrays, you can’t add the two together. Each element must be added individually.
There are functions within C that let you allocate space for variables and arrays onthe- fly.
All of them, but one at a time. A given array can contain only a single data type.
0. Regardless of the size of an array, all C arrays start with subscript 0.
n-1
The program compiles and runs, but it produces unpredictable results.
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.