#include <stdio.h>
#include <stdlib.h>
int main() {
// Memory reallocation
int *dynamicArray;
int newSize;
dynamicArray = (int *)malloc(5 * sizeof(int));
if (dynamicArray == NULL) {
printf("Memory allocation failed.\n");
return 1;
}
// Use the dynamically allocated array
printf("Enter the new size of the array: ");
scanf("%d", &newSize);
dynamicArray = (int *)realloc(dynamicArray, newSize * sizeof(int));
if (dynamicArray == NULL) {
printf("Memory reallocation failed.\n");
return 1;
}
// Use the resized array
// Free the allocated memory
free(dynamicArray);
return 0;
}