Here's your approach for dynamic arrays:
Read , the number of elements needed.
Allocate an array: int* arr = new int[n];
Read or compute values into arr[0] through arr[n-1].
Process the array as needed (sum, search, transform).
Output results.
Free the memory: delete[] arr;
Set pointer to nullptr to prevent accidental reuse. The delete[] must come after all array usage is complete but before the function ends.