Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Let us say that ip is a pointer pointing to an item in an integer array

Let us say that ip is a pointer pointing to an item in an integer array

Computer Science

Let us say that ip is a pointer pointing to an item in an integer array. Which of the following expressions point to the valid items within the array? ip[-2] or ip[2]? Why?

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

The index of an array must be non-negative integer. So:

ip[-2] is invalid since the index cannot be negative number;
ip[2] is valid if the length of the array is greater than or equal to 3;
ip[2] is invalid too if the length of the array is less than 3, index 2 will overflow.