0
0
Cprogramming~20 mins

Pointer declaration - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pointer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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;
}
AAddress of x
B0
C10
DCompilation error
Attempts:
2 left
💡 Hint
Remember that *p means the value pointed to by p.
Predict Output
intermediate
1: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;
AUndefined value
BThe address of x
CThe value 5
DNULL
Attempts:
2 left
💡 Hint
Pointers store addresses, not values directly.
📝 Syntax
advanced
1:30remaining
Identify the correct pointer declaration
Which of the following is a correct declaration of a pointer to an integer?
Aint *p;
Bint p*;
Cint &p;
Dpointer int p;
Attempts:
2 left
💡 Hint
The asterisk * goes before the pointer name to declare a pointer.
🧠 Conceptual
advanced
2:00remaining
Pointer declaration with multiple variables
What is the type of variables a and b after this declaration? int *a, b;
Aa is a pointer to int; b is an int
Ba and b are both pointers to int
Ca and b are both ints
Da is an int; b is a pointer to int
Attempts:
2 left
💡 Hint
The asterisk applies only to the variable it precedes.
🔧 Debug
expert
2:30remaining
Find the error in pointer declaration
What error does this code produce? int *p; *p = 10;
C
int *p;
*p = 10;
ANo error, prints 10
BCompilation error: missing semicolon
CType error: incompatible types
DSegmentation fault or undefined behavior
Attempts:
2 left
💡 Hint
p is declared but not initialized before dereferencing.