Exercises
Explore how pointers work in C through questions about memory addresses, address-of and dereference operators, pointer assignment, arrays, dynamic allocation, null pointers, dangling pointers, and multiple levels of indirection. This quiz combines conceptual knowledge, code tracing, memory diagrams, and practical safety rules.
Answer the questions below and check the explanation for each answer.
0/7 answered
Auto audio on: the next questions will be read aloud when you click Continue.
The address-of operator & returns a variable's memory address. Therefore, &x can be assigned to a compatible pointer.
Because p points to x, assigning 12 through *p changes the value stored in x to 12.
Pointer arithmetic is scaled by the pointed-to type. For an int *, adding 1 advances to the next int array element.
free(p) releases the allocation but does not change p. Its stored address no longer identifies a live allocated object, so p is dangling.
The second assignment changes p so that it points to b. Dereferencing p therefore reads b, whose value is 5.
The first dereference of pp accesses p, and the second dereference follows p to x. Thus, **pp accesses the integer x.
In const int *p, const applies to the pointed-to integer as accessed through p. The pointer itself may still be reassigned.
Video Courses
Ideal for beginners
Thousands of online courses in video, ebooks and audiobooks.
To test your knowledge during online courses
Generated directly from your cell phone's photo gallery and sent to your email
Download our app via QR Code or the links below:.
+ 10 million
students
Free and Valid
Certificate
60 thousand free
exercises
4.8/5 rating in
app stores
Free courses in
video and ebooks