Vidyalelo
C++ Programming · all questions

Pointers and References in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

98

Questions

1/5

Page

Pick an option on a question to see the right answer and solution.

What is a pointer in C++?

Select an option to see the answer and solution.

How do you declare a pointer variable in C++?

Select an option to see the answer and solution.

What is the output of the following code: int x = 5; int *ptr = &x; cout << *ptr; in C++?

Select an option to see the answer and solution.

What is the correct syntax to dereference a pointer in C++?

Select an option to see the answer and solution.

What is the purpose of the 'nullptr' keyword in C++?

Select an option to see the answer and solution.

What does the 'nullptr' keyword replace in C++11 and later versions?

Select an option to see the answer and solution.

What is the purpose of the 'reference' in C++?

Select an option to see the answer and solution.

What is the output of the following code: int x = 5; int &ref = x; cout << ref; in C++?

Select an option to see the answer and solution.

What happens when a reference is declared but not initialized in C++?

Select an option to see the answer and solution.

How do you declare a reference variable in C++?

Select an option to see the answer and solution.

What is the purpose of a null pointer in C++?

Select an option to see the answer and solution.

What is the output of the following code: int arr[3] = {1, 2, 3}; int *ptr = arr; cout << *(ptr + 1); in C++?

Select an option to see the answer and solution.

What is a dangling pointer in C++?

Select an option to see the answer and solution.

What is the address-of operator in C++?

Select an option to see the answer and solution.

What is the output of the following code: int arr[] = {1, 2, 3}; cout << *arr; in C++?

Select an option to see the answer and solution.

How do you declare a constant pointer to an integer variable in C++?

Select an option to see the answer and solution.

What is a pointer to a pointer known as in C++?

Select an option to see the answer and solution.

What does the 'new' keyword do in C++?

Select an option to see the answer and solution.

What is a null reference in C++?

Select an option to see the answer and solution.

What is the output of the following code: int x = 10; int *ptr = &x; cout << *ptr << " " << ptr; in C++?

Select an option to see the answer and solution.