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 3 of 6.

Vasavi said:   1 decade ago
*a means value, right. So *a=1 have to print. But why here *a=1002 is printed? any one explain me clear.

Mahendra said:   1 decade ago
a[i][j][k] is nothing but *(*(*(a+i)+j)+k).

Where 'a' is the base address of the 3D array.

Preety said:   1 decade ago
When we use %u and then use either *p or &p. What will they print the value or address?

Preety said:   1 decade ago
Is this problem also have any link with format specifier or its jst with dimension of array?

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

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

In that values which 1 should take?

I did'nt under stand?

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].

Sowmya said:   9 years ago
*a actually returns the value but how come it returns address? Can anyone explain?

Pushparj Manikam said:   5 years ago
a,*a,**a is base address.

***a is return the value of base address.

Karthi said:   1 decade ago
I didn't understand this.

Please give explanation in easiest way.


Post your comments here:

Your comments will be displayed after verification.