What is the output of the following 3D Array
int arr[3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12};
what is the output for arr[2][1][0]?

Answer Posted / tushar aggarwal

11 is the output of the arr[2][1].
let it understand in a very simple manner.
if we analyze the arr[3][2][2] in a 3d style ,it would be
easy to capture the answer.
1 2
3 4

5 6
7 8

9 10
11 12
here you can see in arr[3][2][2]. there are 3 rows,of 2x2
matrix each.
now coming to the real problem we have to find arr[2][1].
since the last bracket is absent in the arr[2][1].thus we
will implement this by our self.now we may read it as
arr[2][1][0],suppose the last bracket contain 0 in it.

finallly we are ready for finding the value ,
arr[2][1][0].
here [2] = last column of the matrix,since the array is
readed as o ,1,2.
[1][0]= in the third row ,[1][0] represents the value 11.
therefore 11 is output of the arr[2][1][0].

Is This Answer Correct ?    20 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When is the copy constructor called?

641


Which operations are permitted on pointers?

579


How would you use the functions sin(), pow(), sqrt()?

749


What is the difference between ++ count and count ++?

595


What is null pointer and void pointer and what is their use?

601






What is a constructor and how is it called?

608


Write a program to concatenate two strings.

599


What is a multiset c++?

565


What are advantages of c++?

577


What is the difference between the indirection operator and the address of oper-ator?

618


Why do we need runtime polymorphism in c++?

572


Differentiate between a template class and class template in c++?

638


Where and why do I have to put the "template" and "typename" keywords?

593


Can I create my own functions in c++?

615


Write a program to add three numbers in C++ utilizing classes.

631