how to make a n*n 2d dynamic array in c++
#include <iostream>
int main() {
int n;
std::cout << "Enter the size of the 2D array: ";
std::cin >> n;
int arr = new int*[n];
for (int i = 0; i < n; ++i) {
arr[i] = new int[n];
}
// Access and modify elements in the 2D array as needed
// Deallocate memory
for (int i = 0; i < n; ++i) {
delete[] arr[i];
}
delete[] arr;
return 0;
}