Click here to Skip to main content
15,894,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what does it mean by array n[2][2][2] and what is the difference between n[2][2] ? How many elements are stored in n[2][2][2]? how can we use this in our program?
Posted

n[2][2][2] is a 3 dimensional array.
n[2][2] is "only" two dimensional.

n[2][2][2] can store 8 elements.

For information on how to use them refer these links:
http://www.cplusplus.com/doc/tutorial/arrays/[^]
http://www.cplusplus.com/forum/articles/7459/[^]
 
Share this answer
 
n[2][2][2] is a three dimensional array.
You can consider Three dimensional array as a CUBE, This cube have 6 faces.
Each face is of dimension 2 x 2.

Hence Three dimesional array n[2][2][2]will have 8 elements in it.
 
Share this answer
 
v2
Comments
Stefan_Lang 23-Nov-11 4:04am    
The analogy to a cube is a good idea, but I feel the reference to the faces (6) doesn't really help - to stay with your analogy you will have to count the corners of a cube, not the faces.
Emilio Garavaglia 23-Nov-11 9:48am    
neither the corner or faces: n[3][3][3] has 27 elements... one of them is in the middle of the cake!
Albert Holguin 23-Nov-11 9:51am    
Yep...lol

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900