Interview Question

What is pointer arithmetic?

Pointer arithmetic is defined around elements of the same array.

💡 Concept ✅ Quick Revision ⚙ C

Answer

Pointer arithmetic moves within an array object or to one position past its end. • Adding one advances by one element, not one byte. • Subtracting pointers is defined only for positions in the same array object. • A one-past pointer may be compared or subtracted but not dereferenced.

💡 C Example

int values[] = {10, 20, 30}; int *pointer = values; pointer++; printf("%d\n", *pointer);

Output

20

⚡ Quick Revision

Pointer arithmetic is defined around elements of the same array.