C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 18)
18.
What will be the output of the program assuming that the array begins at location 1002?
#include<stdio.h>

int main()
{
    int a[2][3][4] = { {1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2}, 
                       {2, 1, 4, 7, 6, 7, 8, 9, 0, 0, 0, 0} };
    printf("%u, %u, %u, %d\n", a, *a, **a, ***a);
    return 0;
}
1002, 2004, 4008, 2
2004, 4008, 8016, 1
1002, 1002, 1002, 1
Error
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
54 comments Page 2 of 6.

Ramya said:   1 decade ago
Need more clear answer.

Alisha said:   1 decade ago
Here a ,*a,and **a are same .....they return starting address of the array.
***a means that a[0][0][0]. so it returns the value 1.

Ram said:   1 decade ago
When we use 3d array, we use *** and 2d for **.

So the value of ***a is a[0, 0, 0].

Venkatesh said:   1 decade ago
@sriram good explanaton I got you dude.

Sneha said:   1 decade ago
@sriram good explanation. It cleared my doubt.

Hameetha said:   1 decade ago
Thanks sriram for clear explanation.

RAJKUMAR said:   1 decade ago
Hi karthi

Here a[2][3][4],1st subscript a[2] explain no of block.means here no of blocks are 2.2nd subscript explain no of rows and 3rd no of columns. here no of rows and columns are 3 and 4.

Example:-

int main()
{
{
1 2 3 4
4 5 6 8 //block 1st,row=3 and columns=4
9 1 1 2
}
{
2 1 4 7
6 7 8 9 //block 2nd
0 0 0 0
}

This is the simplest way of explanation.

I hope you better understand. O K BYE BYE.

Suresh said:   1 decade ago
How the value 1 will come ?

In that values which 1 should take?

I did'nt under stand?

Uttam raj said:   1 decade ago
I didn't the answer but when i execute the is completely different from the options..... when i execute the answer i got is
(3209883548, 3209883548, 3209883548, 1).....how this is possible

Vishal said:   1 decade ago
@uttam Raj
This is assume that array begins from location 1002 but actualy it different.


Post your comments here:

Your comments will be displayed after verification.