Which of the following statement(s) is/are correct w.r.t 'C' language? (i) A part of the array can be passed to the function instead of the whole array. (ii) Numeric array elements cannot be assigned initial values if the array is defined as a pointer variable.

Which of the following statement(s) is/are correct w.r.t 'C' language? (i) A part of the array can be passed to the function instead of the whole array. (ii) Numeric array elements cannot be assigned initial values if the array is defined as a pointer variable. Correct Answer (i) and (ii) both 

Key Points

The correct answer is option 2.

Option 1: A part of the array can be passed to the function instead of the whole array.

True, C language does not allow to pass an entire array as an argument to a function. However, You can pass a pointer to an array by specifying the array's name without an index.

Option 2: Numeric array elements cannot be assigned initial values ​​if the array is defined as a pointer variable.

True,  If the array is defined as a pointer variable An array is a pointer, and you can store that pointer into any pointer variable of the correct type.

For example,

int A;

int* p = A;

p = 0; makes variable p point to the first member of array A.

Setting p = 0 is equivalent to setting A = 0, since pointers p and A are the same. When numeric array elements cannot be assigned initial values it just assign the address of the array and pointer variable like int* p = A.

Hence the correct answer is both (i) and (ii).

Related Questions

The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is ____________
The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is