1. Which symbol is used to declare a pointer?
(A) &
(B) %
(C) >
(D) *
2. How do you declare a pointer to an integer?
(A) int ptr;
(B) int *ptr;
(C) int &ptr;
(D) pointer int ptr;
3. How do you initialize a pointer to an integer variable x?
(A) int *ptr = x;
(B) int *ptr = &x;
(C) int *ptr = *x;
(D) int ptr = &x;
4. What is the value of a pointer if it is declared but not initialized?
(A) 0
(B) Null
(C) Garbage/undefined
(D) Address of zero
5. Which of the following is a valid null pointer initialization?
(A) int *ptr = 0;
(B) int *ptr = NULL;
(C) int *ptr = nullptr;
(D) All of the above
6. Which operator is used to access the value pointed to by a pointer?
(A) &
(B) *
(C) >
(D) %
7. What does the following code print?
int x = 10;
int *ptr = &x;
cout << *ptr;
(A) Address of x
(B) 10
(C) Garbage value
(D) Error
8. Which of the following pointer declarations is invalid?
(A) int p1, p2;
(B) int p1, p2;
(C) int p1 = nullptr;
(D) int ptr;
9. What does the code ptr = &x; do?
(A) Assigns value of x to ptr
(B) Throws an error
(C) Declares a pointer
(D) Assigns address of x to ptr
10. Which is true about a null pointer?
(A) It points to garbage value
(B) It points to address 0
(C) It can be dereferenced safely
(D) It stores some random address
11. What is the output?
int x = 5;
int *ptr = &x;
*ptr = 10;
cout << x;
(A) 5
(B) Garbage
(C) 10
(D) Error
12. Which operation increases the pointer to point to the next memory location of its type?
(A) ptr++
(B) ptr–
(C) *ptr
(D) &ptr
13. What is the output?
int arr[3] = {1,2,3};
int *ptr = arr;
cout << *(ptr + 2);
(A) 1
(B) 2
(C) 3
(D) Error
14. Which of the following is true about pointer arithmetic?
(A) Adding an integer to a pointer moves it by that many bytes
(B) Adding an integer to a pointer moves it by that many elements of its type
(C) Pointer arithmetic is not allowed in C++
(D) Only subtraction is allowed
15. How do you declare a pointer to a pointer?
(A) int ptrptr;
(B) int **ptrptr;
(C) int ptr;
(D) int &ptrptr;
16. How do you assign the address of a pointer ptr to a pointer-to-pointer pptr?
(A) pptr = *ptr;
(B) pptr = ptr;
(C) pptr = &ptr;
(D) pptr = &&ptr;
17. How do you access the value of the original variable using a pointer-to-pointer?
(A) **pptr
(B) *pptr
(C) &pptr
(D) pptr
18. What is the output?
int x = 10;
int *ptr = &x;
int **pptr = &ptr;
cout << **pptr;
(A) Address of x
(B) 10
(C) Garbage
(D) Error
19. Which statement about pointers is FALSE?
(A) Pointers can be null
(B) Pointers can be dereferenced
(C) Pointers can point to functions
(D) Pointers automatically delete themselves when out of scope
20. Which of the following is correct pointer initialization for an array arr?
(A) int *ptr = arr;
(B) int *ptr = &arr[0];
(C) Both (A) and (B)
(D) int ptr = arr;