Which of the following correctly declare an array that can hold up to 3 rows of 5 columns of doubles? float array[3][5]; int array[3],[5]; int array[3][5]; float array[3,5];
Real Tutor Solution
Answer
Solution
Reviewed and approved by the UpStudy tutoring team
The Deep Dive
The first option, `float array[3][5];`, is correct and clearly defines a 2D array that holds up to 3 rows and 5 columns of floating-point numbers (doubles). It’s a classic way to declare an array in C/C++ where both dimensions must be specified in square brackets. Now, let’s get real for a second! Picture a spreadsheet where you want to store a tidy table of data: 3 rows for category labels and 5 columns for their associated values. This array mistake is like trying to fit a round peg in a square hole—just doesn’t work! Always double-check your syntax when declaring arrays. Happy coding!