Complete the code to declare a pointer to an integer.
int x = 10; int * [1] = &x;
We declare a pointer variable by specifying its name, here p. The asterisk (*) is used when defining the pointer type, not in the variable name.
Complete the code to access the value pointed to by the pointer.
int x = 20; int *p = &x; int y = [1]p;
The asterisk (*) operator is used to dereference a pointer, which means accessing the value stored at the address the pointer holds.
Fix the error in the code to correctly assign the pointer.
int x = 30; int *p; p = [1]x;
To assign a pointer to the address of a variable, use the address-of operator '&'.
Fill both blanks to create a pointer to a pointer and access the original value.
int x = 40; int *p = &x; int **pp = [1]; int y = [2]pp;
To create a pointer to a pointer, assign the address of the first pointer using '&p'. To access the original value, dereference twice using '**pp'.
Fill all three blanks to create a dynamic array, assign values, and access an element.
int *arr = new int[[1]]; arr[0] = [2]; int first = arr[[3]];
We create a dynamic array of size 5, assign 10 to the first element (index 0), and access that element.