Challenge - 5 Problems
Pointer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of pointer declaration and usage
What is the output of this C code snippet?
C
#include <stdio.h> int main() { int x = 10; int *p = &x; printf("%d\n", *p); return 0; }
Attempts:
2 left
💡 Hint
Remember that *p means the value pointed to by p.
✗ Incorrect
The pointer p stores the address of x. Using *p accesses the value of x, which is 10.
❓ Predict Output
intermediate1:30remaining
Value of pointer variable after declaration
What is the value of the pointer variable p after this code runs?
C
int x = 5; int *p = &x;
Attempts:
2 left
💡 Hint
Pointers store addresses, not values directly.
✗ Incorrect
The pointer p is assigned the address of x using &x, so p holds x's address.
📝 Syntax
advanced1:30remaining
Identify the correct pointer declaration
Which of the following is a correct declaration of a pointer to an integer?
Attempts:
2 left
💡 Hint
The asterisk * goes before the pointer name to declare a pointer.
✗ Incorrect
In C, 'int *p;' declares p as a pointer to an int. Other options are invalid syntax.
🧠 Conceptual
advanced2:00remaining
Pointer declaration with multiple variables
What is the type of variables a and b after this declaration?
int *a, b;
Attempts:
2 left
💡 Hint
The asterisk applies only to the variable it precedes.
✗ Incorrect
Only a is declared as a pointer to int. b is a normal int variable.
🔧 Debug
expert2:30remaining
Find the error in pointer declaration
What error does this code produce?
int *p;
*p = 10;
C
int *p; *p = 10;
Attempts:
2 left
💡 Hint
p is declared but not initialized before dereferencing.
✗ Incorrect
Pointer p is uninitialized and points to an unknown location. Writing *p = 10 causes undefined behavior or crash.