what is the use of multi-dimensional arrays if we can do that work in single-dimentional array also? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is the use of multi-dimensional arrays if we can do that work in single-dimentional array also?

12th Oct 2016, 10:38 AM
Mihir
3 Answers
+ 1
In my openion, using a multidimensional array helps you to shorten the code, as it helps us to create a single entity instead of multiple entities. for e.g., int area_rectangle = new int[3][3]; now you can use this single "area_rectangle"for your calculation. whereas, with single dimensional array you will have to create one array for length, and another for breadth. In other words, it's just to make life easier for the developer in certain circumstances while the underlying data is still in the form of single dimensional array.
12th Oct 2016, 11:20 AM
Chetan Sapra
Chetan Sapra - avatar
0
Convenience. I prefer to type arr[i][j] rather than arr[i*row_size+j]. How about you?
12th Oct 2016, 11:02 AM
Zen
Zen - avatar
0
The people who get confused with multi-dimensional arrays use single arrays. multi-dimensional arrays is quite confusing especially if you are new to arrays. For short codes and faster programs, multi-dimentional arrays are neccessary especially when it has to deal with large programs involving several encryption / decryption algorithms.
21st Oct 2016, 6:34 AM
Franky BrainBox
Franky BrainBox - avatar