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]?
Answers were Sorted based on User's Feedback
Answer / zohaib brohi
the output will be 11..
first we should make it simple.
just make all the values in that array of 2x2 in 3 block like
1,2,
3,4,
5,6,
7,8,
9,10,
11,12
now we have to find [2][1][0]. it means that the value is in
3rd block becoz array starts from 0, then [1][0] means 1st
value of 2nd row.. so thats 11.
Is This Answer Correct ? | 112 Yes | 9 No |
Answer / 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 |
Answer / darshil movaliya
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]?
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / arpita
ans-0 [3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12}
[2][1][0]={0}
3*2*2=12
2*1*0=0
think hatke...
Is This Answer Correct ? | 9 Yes | 29 No |
What is type of 'this' pointer? Explain when it is get created?
How long it will take to learn c++?
What are the uses of pointers?
What is the default width for ouputting a long integer using the insertion operator?
What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"?
Define pure virtual function?
Does there exist any other function which can be used to convert an integer or a float to a string?
What does it mean to declare a member variable as static?
difference between the c++ and c languages
How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?
Is oops and c++ same?
what is a class? Explain with an example.