C | Arrays | Question 2
Predict the output of below program:
#include <stdio.h> int main() { int arr[5]; // Assume base address of arr is 2000 and size of integer is 32 bit printf("%u %u", arr + 1, &arr; + 1); return 0; } |
chevron_right
filter_none
(A) 2004 2020
(B) 2004 2004
(C) 2004 Garbage value
(D) The program fails to compile because Address-of operator cannot be used with array name
Answer: (A)
Explanation: Name of array in C gives the address(except in sizeof operator) of the first element. Adding 1 to this address gives the address plus the sizeof type the array has. Applying the Address-of operator before the array name gives the address of the whole array. Adding 1 to this address gives the address plus the sizeof whole array.
Recommended Posts:
- C | Arrays | Question 5
- C | Arrays | Question 7
- C | Arrays | Question 11
- C | Arrays | Question 13
- C | Arrays | Question 3
- C | Arrays | Question 6
- C | Arrays | Question 9
- C | Arrays | Question 1
- C | Arrays | Question 14
- C | Arrays | Question 4
- C | Arrays | Question 14
- C | Arrays | Question 10
- C | Arrays | Question 12
- Java | Arrays | Question 6
- Java | Arrays | Question 7



