MCQ Hive stays free thanks to ads. Please disable your ad blocker for this site so content and features keep working.
Data Types
Arrays & Memory Layout
Beginner
Q
Inside void f(int arr[10]), what does sizeof(arr) return on a 64-bit system?
ACompilation error
B10
C8 (the size of a pointer)
D40
Correct Answer:
C. 8 (the size of a pointer)
Explanation:
Array parameters are adjusted to pointers, so the [10] is ignored.
ALSO KNOW (related points):
• Is int n; cin >> n; int a[n]; standard C++? → No; variable-length arrays are not part of standard C++ (some compilers accept them as an extension)
• What is the time complexity of accessing the i-th element of a singly linked list? → O(n)