0
0
Cprogramming~5 mins

Address and dereference operators - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the address operator (&) do in C?
The address operator (&) gives the memory address of a variable. It tells where the variable is stored in memory.
Click to reveal answer
beginner
What is the purpose of the dereference operator (*) in C?
The dereference operator (*) accesses the value stored at a given memory address (pointer). It lets you read or change the value the pointer points to.
Click to reveal answer
beginner
Explain the difference between a pointer and a normal variable.
A normal variable stores a value directly. A pointer stores the address of another variable, not the value itself.
Click to reveal answer
beginner
Given int x = 10; int *p = &x;, what does *p represent?
*p represents the value stored at the address held by p. Here, it is the value of x, which is 10.
Click to reveal answer
intermediate
Why is it important to use the dereference operator carefully?
Using the dereference operator on an invalid or uninitialized pointer can cause errors or crashes because it tries to access memory that may not belong to your program.
Click to reveal answer
What does the & operator do in C?
AReturns the address of a variable
BDereferences a pointer
CDeclares a pointer variable
DAssigns a value to a variable
If int *p = &x;, what does *p mean?
AThe address of x
BA new pointer
CThe value of x
DThe size of x
Which operator is used to get the value stored at a pointer's address?
A&
B*
C->
D%
What happens if you dereference a pointer that is not initialized?
AThe program may crash or behave unpredictably
BYou get the value zero
CIt automatically initializes the pointer
DNothing happens
Which of the following is a correct way to declare a pointer to an int?
Apointer int p;
Bint p;
Cint &p;
Dint *p;
Describe how the address (&) and dereference (*) operators work together with pointers in C.
Think about how you find where something is and then how you look inside it.
You got /3 concepts.
    Explain why using the dereference operator on an invalid pointer is dangerous.
    Consider what happens if you try to open a door that doesn't exist.
    You got /3 concepts.