|
C Programming Reference >> C Programming Reference Question Bank >> 19/07/07 - 453 Views - No Ratings Yet Level - Intermediate Question - What will be the output of the following code?
Answer - 2 5 Explanation - Here 'a' is an array of 5 elements. Now reason for 2 is very simple since *(a+1) is equivalent to a[1]. Now a little difficult part is how the second value displayed is 5. The reason for this (&a + 1) returns the address of next memmory location just after array. It should not be confused with &(a+1) which will return address of a[1]. So now when we display *(ptr - 1) value of last element of array a that is 5 is displayed. Reader Comments -
|
|||