Write a C program that:
- Asks the user for the number of elements they want to input.
- Dynamically allocates memory for that many integers using
malloc. - Accepts input for each integer.
- Calculates and prints the sum of all entered integers.
- Finally, frees the allocated memory.
- To access elements of a dynamically allocated array of integers, you can use pointer arithmetic or array indexing.
- Always ensure that dynamically allocated memory is freed using
free()to prevent memory leaks.
After entering a specific number of integers, the program should display their sum.