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 7 of 7.
Shrinivas Patgar said:
1 decade ago
In 1D array int a[5] = {1,2,3}; a[0] is equal to *(a+0) is same as *(0+a) is same as 0[a] whose value is 1.
In 2D array int a[2][2] = {1,2,3}; a[0][0] is equal to *(a[0]+0) is same as *(*(a+0)+0) whose value is 1.
In 2D array int a[2][2] = {1,2,3}; a[0][0] is equal to *(a[0]+0) is same as *(*(a+0)+0) whose value is 1.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers