0

What is an array?

c++

23rd Apr 2017, 10:58 AM
Mwesigwa Arnold
Mwesigwa Arnold - avatar
3 Answers
+ 1
an array is a collection of numbers strings or objects (depending on how you instantiate it) that has predefined size. if it is one dimensional think of it like a dorm of a jail. in a dorm of a jail there are fixed number of cells one next to each other. and each cell contains a different object of the same type.
23rd Apr 2017, 11:09 AM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
0
You can think of a 3D array as a rubix cube or a 2D array as the face of a rubix cube or a 1D array as one row of a rubix cube. Each square is of the same type which is a color but each square has a different color. While you can also have some squares equal the same value as other squares. To figure out the number of squares in an array times all the numbers together. You have a 3D array thats set as [3][4][5]. This will equal 60 squares for the array. Also note that if you continue to add on additional dimensions the size of the array will continue to increase. An int variable is 4 bytes. If you have an array with 60 ints the size of the array will be 60*4 bytes. The reason this may help you in C++ is because if you want a variable to hold the size of your array you can simply put: Array_Size = (sizeOf(Array) / sizeOf(int)) || (sizeOf(Array) / sizeOf(Array[0])) // This is not a valid statement I put "||" to show an alternative.
23rd Apr 2017, 5:11 PM
Ty Ler
Ty Ler - avatar
- 1
see sololearn course
23rd Apr 2017, 11:40 AM
Mayur Chaudhari
Mayur Chaudhari - avatar