Pointer Arithmetic - C programming

Assume that ip has been declared to be a pointer to int and that result has been declared to be an array of 100 elements . Assume further that ip has been initialized to point to an element in the first half of the array .

Write an expression whose value is the element in the array after the element that ip points to.

First Attempt :
*ip + *(ip+1) + *(ip+2)

Second Attempt:
int sum = ip[0] + ip[1] + ip[2];

Third Attempt:
*ip + 1
Last edited on
*(ip+1) <- advance the pointer one element and dereference the resulting pointer.
Topic archived. No new replies allowed.