Pointer declaration and initialization — C++ MCQs

20
Score: 0
Attempted: 0/20
1. Which symbol is used to declare a pointer?



2. How do you declare a pointer to an integer?



3. How do you initialize a pointer to an integer variable x?



4. What is the value of a pointer if it is declared but not initialized?



5. Which of the following is a valid null pointer initialization?



6. Which operator is used to access the value pointed to by a pointer?



7. What does the following code print?
int x = 10;
int *ptr = &x;
cout << *ptr;




8. Which of the following pointer declarations is invalid?



9. What does the code ptr = &x; do?



10. Which is true about a null pointer?



11. What is the output?
int x = 5;
int *ptr = &x;
*ptr = 10;
cout << x;




12. Which operation increases the pointer to point to the next memory location of its type?



13. What is the output?
int arr[3] = {1,2,3};
int *ptr = arr;
cout << *(ptr + 2);




14. Which of the following is true about pointer arithmetic?



15. How do you declare a pointer to a pointer?



16. How do you assign the address of a pointer ptr to a pointer-to-pointer pptr?



17. How do you access the value of the original variable using a pointer-to-pointer?



18. What is the output?
int x = 10;
int *ptr = &x;
int **pptr = &ptr;
cout << **pptr;




19. Which statement about pointers is FALSE?



20. Which of the following is correct pointer initialization for an array arr?



Contents Copyrights Reserved By T4Tutorials