GeekInterview.com
Series: Subject: Topic:
Question: 240 of 338

how does three dimensional array works?

Asked by: Interview Candidate | Asked on: Oct 13th, 2006
Showing Answers 1 - 3 of 3 Answers
Guest

Answered On : Oct 17th, 2006

A 3-D array can be considered as an array of a 2-Dimensional array and thats very simple to understand. Consider an example ,say we have an array declaration int A[2][3][2],thats a 3-D array.We need to develop a decoding scheme to interpret the meaning of such declarations.Read it like this: int (A[2])[3][2] (Note the braces) .'A' is an array of 2 elements and these 2 elements are not simple integers as it would have been in the case if 'A' was a 1-D array.Here ,the two elements that 'A' is made up of a 2-D array of dimensions 3*2 .i.e A 3-D array in this case is nothing but a collection of two 2-D arrays in our example.in other words ,we say that 'A' is made of 2 pages ,3 rows and 2 columns each,in all we have total=2*3*2=12 elements in our arraybut this is just a logical explanation ,physically an array be it any dimensional ,is always stored sequentially as memory is Linear.

Yes  2 Users have rated as useful.
  
Login to rate this answer.
hanuman

Answered On : Nov 13th, 2006

let us take an example     main(){int a[2][2][2];int i,j,k;for(i=0;i<2;i++)  for(j=0;j<2;j++)      for(k=0;k<2;k++)       {           printf("i= %dnj=%dnk=%dnnn ",i,j,k);              printf("enter the value to store at the specified postionn");              scanf("%d",a[i][j][k]);                  }getch();}if u compile and execute the above prg it shows the values of the variables i,j,k  and where it stores.  by this u can make that how the three dimensional array works

Yes  2 Users have rated as useful.
  
Login to rate this answer.
sravan

Answered On : Nov 18th, 2006

a 3-d array is collection 2-d arrays as rows.ex: a[2][3][4] means 'a' contains two 2-d arrays of each size [3][4].first subscript 2 indicates that 'a' contains two arrays which have 3-rows and 4-coloumns.

Yes  2 Users have rated as useful.
  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.