malloc addition

#include <stdio.h>
#include <stdlib.h>

int main() {
    int arr1, arr2, *sum;
    int size, i;

    // Get the size of the arrays
    printf("Enter the size of the arrays: ");
    scanf("%d", &size);

    // Allocate memory for the arrays
    arr1 = (int)malloc(size  sizeof(int));
    arr2 = (int)malloc(size  sizeof(int));
    sum = (int)malloc(size  sizeof(int));

    // Check if memory allocation is successful
    if (arr1 == NULL || arr2 == NULL || sum == NULL) {
        printf("Memory allocation failed. Exiting program.\n");
        exit(1);
    }

    // Input elements for the first array
    printf("Enter elements for the first array:\n");
    for (i = 0; i < size; i++) {
        scanf("%d", &arr1[i]);
    }

    // Input elements for the second array
    printf("Enter elements for the second array:\n");
    for (i = 0; i < size; i++) {
        scanf("%d", &arr2[i]);
    }

    // Add corresponding elements of the two arrays
    for (i = 0; i < size; i++) {
        sum[i] = arr1[i] + arr2[i];
    }

    // Display the result
    printf("Resultant array after addition:\n");
    for (i = 0; i < size; i++) {
        printf("%d ", sum[i]);
    }

    // Free allocated memory
    free(arr1);
    free(arr2);
    free(sum);

    return 0;
}