filling dynamic array with a specific value in c++
#include <iostream>
int main() {
int size;
std::cout << "Enter the size of the array: ";
std::cin >> size;
int *arr = new int[size];
int value;
std::cout << "Enter the value to fill the array with: ";
std::cin >> value;
for (int i = 0; i < size; ++i) {
arr[i] = value;
}
// Display the array
std::cout << "The array filled with " << value << " is: ";
for (int i = 0; i < size; ++i) {
std::cout << arr[i] << " ";
}
delete[] arr;
return 0;
}