1. If int arr[5] = {1,2,3,4,5}; and int *p = arr;, what does *(p+2) return?
(A) 1
(B) 2
(C) 3
(D) 4
2. Which operator is used to move a pointer to the next element of its type?
(A) +
(B) ++
(C) *
(D) &
3. What is the output of the following?
int arr[3] = {10,20,30};
int *ptr = arr;
ptr++;
cout << *ptr;
(A) 10
(B) 20
(C) 30
(D) Garbage
4. If int *p points to an array element, what does p-1 do?
(A) Moves pointer forward
(B) Throws error
(C) Decrements value stored in pointer
(D) Moves pointer backward
5. Pointer arithmetic depends on
(A) Size of data type
(B) Value of pointer
(C) Compiler version
(D) Operating system
6. What does the expression ptr + 3 do for int *ptr?
(A) Moves pointer 3 bytes
(B) Moves pointer 3 int elements forward
(C) Moves pointer backward
(D) Adds 3 to the value pointed by ptr
7. What is the output?
int arr[4] = {5,10,15,20};
int *p = arr;
cout << *(p+3);
(A) 5
(B) 10
(C) 15
(D) 20
8. Which of the following is valid pointer subtraction?
(A) int diff = ptr2 – ptr1;
(B) int diff = ptr1 + ptr2;
(C) int diff = ptr1 * ptr2;
(D) int diff = ptr1 / ptr2;
9. What is the result of subtracting two pointers pointing to the same array?
(A) The difference in bytes
(B) The difference in number of elements
(C) Always zero
(D) Compiler error
10. Can you perform ptr + 1.5 if ptr is an int pointer?
(A) Yes
(B) No
(C) Only in C++11
(D) Only for float pointers
11. What does ptr++ do compared to ++ptr?
(A) Both are the same
(B) ptr++ increments first; ++ptr uses original value
(C) ptr++ uses original value, then increments; ++ptr increments first
(D) None of the above
12. Pointer arithmetic is only valid for
(A) Single variables
(B) Arrays and dynamically allocated memory
(C) Functions
(D) References
13. If double arr[3] = {1.1,2.2,3.3}; and double *p = arr;, what is p + 1?
(A) Moves 1 byte forward
(B) Moves 2 bytes forward
(C) Moves 4 bytes forward
(D) Moves 1 double element forward
14. What happens if pointer goes outside array bounds?
(A) Compiler error
(B) Runtime error
(C) Undefined behavior
(D) Automatically wraps around
15. How do you calculate the number of elements between two pointers p1 and p2 in the same array?
(A) p2 + p1
(B) p2 – p1
(C) p1 * p2
(D) p1 / p2
16. If int *p = &arr[0];, what does *(p + 2) equal?
(A) arr[0]
(B) arr[1]
(C) arr[2]
(D) arr[3]
17. Which pointer types allow pointer arithmetic?
(A) Only int pointers
(B) Only char pointers
(C) Any pointer pointing to an array or contiguous memory
(D) Function pointers only
18. What is the output?
int arr[5] = {1,2,3,4,5};
int *p = arr+4;
cout << *(p-2);
(A) 3
(B) 2
(C) 1
(D) 4
19. Which of the following is INCORRECT?
(A) ptr + n moves pointer forward
(B) ptr – n moves pointer backward
(C) ptr * n multiplies pointer
(D) ptr1 – ptr2 gives number of elements between them