Complete the code to declare a reference to an integer variable.
int x = 10; int& [1] = x;
In C++, a reference is declared using the & symbol after the type. Here, r is the reference name.
Complete the code to declare a pointer to an integer variable.
int x = 20; int [1] p = &x;
A pointer is declared using the * symbol before the variable name.
Fix the error in the code to correctly assign a pointer to an integer variable.
int x = 30; int* p; p = [1]x;
To assign a pointer to the address of a variable, use the & operator before the variable name.
Fill both blanks to create a reference and a pointer to the same integer variable.
int value = 40; int& [1] = value; int* [2] = &value;
Here, r is the reference name and p is the pointer name, both referring to value.
Fill all three blanks to correctly dereference a pointer and assign its value to a reference.
int num = 50; int* [1] = # int& [2] = [3];
p is the pointer to num, r is the reference assigned to the value pointed by p using *p.