Complete the code to declare a pointer to an integer variable.
int x = 10; int [1] ptr = &x;
The asterisk (*) is used to declare a pointer variable in C++.
Complete the code to assign the address of variable x to pointer ptr.
int x = 5; int* ptr; ptr = [1]x;
The ampersand (&) operator gives the address of a variable.
Fix the error in the code to correctly print the value pointed to by ptr.
int x = 20; int* ptr = &x; std::cout << [1]ptr << std::endl;
Using *ptr dereferences the pointer to get the value it points to.
Fill both blanks to declare a pointer and assign it the address of variable y.
int y = 15; [1] ptr = [2]y;
int* declares a pointer to int, and &y gets the address of y.
Fill all three blanks to declare a pointer, assign it the address of z, and print the value pointed to by ptr.
int z = 30; [1] ptr = [2]z; std::cout << [3]ptr << std::endl;
int* declares the pointer, &z gets the address, and *ptr dereferences to the value.
