
Two-dimensional array:
A two dimensional array is also called as a multi-dimensional array; a multidimensional array is that all the identical arrays are put together into a single array.
- This is useful for storing same type of multiple sets of data in same place.
- The main advantage is that one-dimensional array can hold only one set of value whereas two-dimensional array can hold multiple sets of data in the form of rows and columns.
- The structure of a multi-dimensional array is lookalike a table (that is combination of rows and columns); it contains same type of columns.
Syntax:
The syntax of two dimensional arrays is as follows:
datatype array_name [number_of_rows][number_of_columns];
Analyzing the given array definition:
Consider the given array definition:
//Declare the two-dimensional array
int numberArray[9][11];
The above code illustrates that the declaration of a two dimensional array named “numberArray” which holds “6” rows and “4” columns; so totally the array can hold “99” elements (that is
- The index number representation for the “99” elements are as follows:
C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | C10 | C11 | |
R1 | (0,0) | (0,1) | (0,2) | (0,3) | (0,4) | (0,5) | (0,6) | (0,7) | (0,8) | (0,9) | (0,10) |
R2 | (1,0) | (1,1) | (1,2) | (1,3) | (1,4) | (1,5) | (1,6) | (1,7) | (1,8) | (1,9) | (1,10) |
R3 | (2,0) | (2,1) | (2,2) | (2,3) | (2,4) | (2,5) | (2,6) | (2,7) | (2,8) | (2,9) | (2,10) |
R4 | (3,0) | (3,1) | (3,2) | (3,3) | (3,4) | (3,5) | (3,6) | (3,7) | (3,8) | (3,9) | (3,10) |
R5 | (4,0) | (4,1) | (4,2) | (4,3) | (4,4) | (4,5) | (4,6) | (4,7) | (4,8) | (4,9) | (4,10) |
R6 | (5,0) | (5,1) | (5,2) | (5,3) | (5,4) | (5,5) | (5,6) | (5,7) | (5,8) | (5,9) | (5,10) |
R7 | (6,0) | (6,1) | (6,2) | (6,3) | (6,4) | (6,5) | (6,6) | (6,7) | (6,8) | (6,9) | (6,10) |
R8 | (7,0) | (7,1) | (7,2) | (7,3) | (7,4) | (7,5) | (7,6) | (7,7) | (7,8) | (7,9) | (7,10) |
R9 | (8,0) | (8,1) | (8,2) | (8,3) | (8,4) | (8,5) | (8,6) | (8,7) | (8,8) | (8,9) | (8,10) |
With the help of assignment operator “=”, the value can be easily assigned to an array.

Want to see the full answer?
Check out a sample textbook solution
Chapter 7 Solutions
STARTING OUT W/C++,...(LL)-W/ACCESS
- 6. See the code below and solve the following. import java.io.*; public class DataStream { } public static void main(String[] args) } DataOutputStream output = new DataOutputStream(new FileOutputStream("temp.dat")); output.writeUTF("Book1"); output.writeInt(85); output.writeUTF("Book2"); output.writeInt(125); output.writeUTF("Book3"); output.writeInt(70); output.close(); // ToDo: Read all data from temp.dat and print the data to the standard output (monitor) 6-1. This program has a compile error, and the message is “Unhandled exception type FileNotFoundException". How do you fix this error? (1 point) 6-2. Is FileNotFoundException a checked exception or an unchecked exception? (1 point) 6-3. What is the difference between checked exception and unchecked exception? (1 point) 6-4. Please complete the above program by reading all data from temp.dat and print the data to the standard output (monitor) by using System.out.print, System.out.println or System.out.printf method. (2 points)arrow_forwardWrite a program that reads a list of integers from input and determines if the list is a palindrome (values are identical from first to last and last to first). The input begins with an integer indicating the length of the list that follows. Assume the list will contain a maximum of 20 integers. Output "yes" if the list is a palindrome and "no" otherwise. The output ends with a newline. Hints: - use a for loop to populate the array based on the specified size (the first number entered) - use a for loop to check first value with last value, second value with second from end, etc. - if the values do not match, set a Boolean variable to flag which statement to output (yes or no) Ex: If the input is (remember to include spaces between the numbers): 6 1 5 9 9 5 1 the output is: yes Ex: If the input is: 5 1 2 3 4 5 the output is: C++ codingarrow_forwardDesign and draw a high-level "as-is" process diagram that illustrates a current process related to a product or service offered through the SSDCI.gov database.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning




