Recall & Review
beginner
What is a pointer in C++?
A pointer is a variable that stores the memory address of another variable. It 'points' to the location where data is stored.
Click to reveal answer
beginner
How do you declare a pointer to an integer in C++?
You declare it using the syntax:
int* ptr; Here, ptr is a pointer to an integer.Click to reveal answer
beginner
What does the asterisk (*) mean in a pointer declaration?
The asterisk (*) indicates that the variable is a pointer type, meaning it holds the address of a variable of the specified type.
Click to reveal answer
beginner
Explain the difference between
int* ptr; and int *ptr;.Both are the same. The position of the asterisk (*) does not change the meaning. It just shows
ptr is a pointer to an int.Click to reveal answer
intermediate
What happens if you declare a pointer but do not initialize it?
The pointer will contain a garbage (random) address. Using it without initialization can cause errors or crashes.
Click to reveal answer
Which of the following declares a pointer to a float?
✗ Incorrect
The correct syntax is
float* ptr; which declares ptr as a pointer to a float.What does the pointer variable store?
✗ Incorrect
Pointers store the memory address of another variable, not the value itself.
How do you declare a pointer to an integer named
p?✗ Incorrect
The correct declaration is
int* p; which means p is a pointer to an int.What is the value of an uninitialized pointer?
✗ Incorrect
An uninitialized pointer contains a random garbage address and should not be used before initialization.
Which symbol is used to declare a pointer?
✗ Incorrect
The asterisk (*) symbol is used to declare a pointer variable.
Describe how to declare a pointer to a variable in C++ and explain what it stores.
Think about how you tell the computer to remember where something is stored.
You got /3 concepts.
What risks are there if you use a pointer without initializing it first?
Consider what happens if you try to use a random address.
You got /3 concepts.