C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 12)
12.
What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?
#include<stdio.h>
int main()
{
int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
return 0;
}
Discussion:
61 comments Page 5 of 7.
SOUMYA said:
9 years ago
Here %u is given instead of %d, %u gives addresS, so would it not display an error?
Vamsi tharun kumar said:
1 decade ago
Why the address start from 1002 why not 520, any one explain about this addresses?
Himanshu said:
8 years ago
How can anyone know the base address?
It can be 448 or another address as well.
It can be 448 or another address as well.
Afri said:
2 decades ago
The formula used is *(*(a+i)+j).i represents the row and j the column.
GCE said:
9 years ago
But printf using control string %u, then how to prints array elements?
Habib said:
1 decade ago
Why cant a[0] be 1, it represents the rvalue, not lvalue I guess !
SYED AZAR said:
1 decade ago
It prints like this in windows only. But in Linux 1010, 2, 2.
Ayesha said:
1 decade ago
Is (a+0) and a[0] is same.
Does *(*(a+0)+1) becomes *(1+1).
Does *(*(a+0)+1) becomes *(1+1).
Shree said:
2 decades ago
I think 1006 is the memory location but why can't it be 520.
Sivakumaran said:
2 decades ago
a[0]+1= 1002+4=> 1006
*(a[0]+1) = 2
*(*(a+0)+1)=???
*(a[0]+1) = 2
*(*(a+0)+1)=???
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers