#include <stdio.h>
#include <stdlib.h>
int main() {
// Allocate memory for an integer array of size 5
int arr = (int )malloc(5 * sizeof(int));
// Check if memory allocation was successful
if (arr == NULL) {
printf("Memory allocation failed.\n");
return 1; // Exit the program with an error code
}
// Assign values to the elements of the array
for (int i = 0; i < 5; i++) {
arr[i] = i * 2;
}
// Display the elements of the array
printf("Array elements: ");
for (int i = 0; i < 5; i++) {
printf("%d ", arr[i]);
}
printf("\n");
// Free the allocated memory
free(arr);
return 0; // Exit the program
}