Arrays in C (original) (raw)
Which of the following correctly declares an array of 10 integers in C?
Which of the following statements about arrays is TRUE in C?
- Arrays can hold different data types.
- The size of an array can be changed during execution.
- An array stores elements of the same type in contiguous memory.
- Arrays are not supported in C.
What is the index of the first element in a C array?
What is the correct way to initialize all elements of an array to zero in C?
Which of the following is NOT a valid array declaration?
- int arr[3] = {1, 2, 3, 4};
What is the value of arr[1] after the following declaration?
C `
int arr[3] = {10};
`
What is true about partially initialized arrays in C?
- All elements must be initialized
- Uninitialized elements get garbage values
- Remaining elements are initialized to zero
Which of the following allows you to iterate over a C array using a pointer?
- for (int *p = arr; p <= arr + size; p++)
- for (int *p = arr; p < arr + size; p++)
- for (int p = arr; p < arr + size; p++)
- for (int p = &arr; p <= arr + size; p++)
What is the difference between int arr[5]; and int *arr = malloc(5 * sizeof(int));?
- The first is static, the second is dynamic
- The second doesn't allocate memory
What happens if you use sizeof on a pointer to an array?
- Gives size of first element
There are 19 questions to complete.
Take a part in the ongoing discussion