What will the output of the below code, be if the base address of the array is 1200?
C++
#include <iostream> using namespace std;
int main()
{ int arr[] = { 1, 2, 3, 4, 5 };
cout << arr << ", " << &arr << ", " << &arr[0] << endl;
return 0;
} |
(A)
1200, 1202, 1204
(B)
1200 1200 1200
(C)
1200, 1204, 1208
(D)
1200, 1204, 1208
Answer: (B)
Explanation:
Given that, the base address of the array is 1200.
- arr, &arr is pointing to the base address of the array arr.
- &arr[0] is pointing to the address of the first element array arr (base address).
Hence the correct option is (B)
Quiz of this Question
Please comment below if you find anything wrong in the above post
Article Tags :
Uncategorized
Recommended Articles