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;
}
Discussion:
54 comments Page 5 of 6.
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].
So the value of ***a is a[0, 0, 0].
Anusha said:
1 decade ago
Can anyone explain this ? what do *a, **a, ***a mean?
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.
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?
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
(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.
This is assume that array begins from location 1002 but actualy it different.
Shabnam said:
1 decade ago
a[2][3][4] means two blocks 3 rows and 4 columns.
now
we can write{
{ 1,2,3,4
5,6,7,8
9,1,1,2}//1st block 3 rows 4 columns
{ 2,1,4,7
6,7,8,9
0,0,0,0}//2nd block 3 rows 4 columns
}
now we have given address of array as 1002.so a represents starting address,*a,**a also represents starting address which is 1002.now ***a represents 1st element i.e. 1 that means a[0][0][0]=1 means first block first row and first column.
and after running this program address will be different depending on your computer
now
we can write{
{ 1,2,3,4
5,6,7,8
9,1,1,2}//1st block 3 rows 4 columns
{ 2,1,4,7
6,7,8,9
0,0,0,0}//2nd block 3 rows 4 columns
}
now we have given address of array as 1002.so a represents starting address,*a,**a also represents starting address which is 1002.now ***a represents 1st element i.e. 1 that means a[0][0][0]=1 means first block first row and first column.
and after running this program address will be different depending on your computer
Hari said:
1 decade ago
Thanks chetan done a nice job.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers