#include <iostream>
int main() {
// Step 1: Declare a pointer variable
int* dynamicArray;
// Step 2: Allocate memory using 'new' operator
dynamicArray = new int[5];
// Step 3: Initialize the dynamically allocated array
for (int i = 0; i < 5; ++i) {
dynamicArray[i] = i * 2;
}
// Step 4: Access and print elements of the dynamically allocated array
for (int i = 0; i < 5; ++i) {
std::cout << "Element " << i << ": " << dynamicArray[i] << std::endl;
}
// Step 5: Deallocate memory using 'delete[]' operator
delete[] dynamicArray;
return 0;
}