What will be printed out as a result of the following code execution?
int main()
{
     int *array = new int[10];
     std::cout << sizeof(array) / sizeof(array[0]);
     delete[] array;
     return 0;
}
Explanation
sizeof does not work for dynamic arrays. It gives you the size of a pointer, since int *array is a pointer. The size of a pointer is platform specific.

No, it actually results in a compilation error, since #include <iostream> is not there.

2019 Jan 24, 10:27:53 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C++ quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes