ProgrammingVery hardGATE CS · Campus placements

Which statement about pointer relations in C is well defined?

  1. A. Comparing pointers into different arrays with < is well defined
  2. B. Comparing pointers into the same array with < is well defined when both point into it or one past its end
  3. C. Subtracting pointers from different arrays is well defined
  4. D. Dereferencing one past the end of an array is well defined

Correct answer: B. Comparing pointers into the same array with < is well defined when both point into it or one past its end

Relational comparison is defined within one array, including the one-past-the-end address. Comparing or subtracting unrelated pointers is undefined, and dereferencing the one-past-the-end address is undefined.

More C Programming questions

Exams that ask this topic