Final answer:
In C, an array can be initialized with 0 using the memset() function, declaring the array with an initial value of 0, or using the calloc() function.
Step-by-step explanation:
The correct options for initializing an array with 0 in C are:
-
- By using the memset() function to set all elements of the array to 0
-
- By declaring the array with an initial value of 0
-
- By using the calloc() function to allocate memory for the array and initialize it with 0
-
For example:
int arr1[10]; memset(arr1, 0, sizeof(arr1)); int arr2[10] = {0}; int* arr3 = calloc(10, sizeof(int));