A

Admin • 833K Points
Coach

Q. Which of the following will correctly initialize a dynamic array of integers with 10 elements?

  • (A) int* arr = new int[10];
  • (B) int arr[10] = new[];
  • (C) int* arr = malloc(10 * sizeof(int));
  • (D) int arr[10] = new int[10];
  • Correct Answer - Option(A)
  • Views: 21
  • Filed under category C++
  • Hashtags:

Explanation by: Admin

In C++, the correct way to initialize a dynamic array is using the 'new' operator like 'int* arr = new int[10];'.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.