When dynamically allocating an array of integers using new, which of the following syntax is correct? 

  • int* arr = new int; 
  • int arr = new int[10]; 
  • int arr[10] = new int; 
  • int* arr = new int[10];
The correct way to dynamically allocate an array of integers in C++ using the new operator is int* arr = new int[10];. This syntax allocates memory for 10 integers on the heap and returns a pointer to the first element.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *