0
0
Cprogramming~10 mins

Pointers to pointers in C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a pointer to a pointer to an integer.

C
int x = 10;
int *p = &x;
int [1] = &p;
Drag options to blanks, or click blank then click option'
A**pp
B*pp
Cpp
D&pp
Attempts:
3 left
💡 Hint
Common Mistakes
Using only one asterisk (*) instead of two.
Forgetting to use a pointer type for pp.
2fill in blank
medium

Complete the code to assign the address of pointer p to pointer to pointer pp.

C
int x = 5;
int *p = &x;
int **pp;
pp = [1];
Drag options to blanks, or click blank then click option'
Ap
B&p
C*p
Dx
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning pp = p; which is incorrect type.
Assigning pp = *p; which dereferences p.
3fill in blank
hard

Fix the error in the code to correctly print the value of x using pointer to pointer pp.

C
int x = 20;
int *p = &x;
int **pp = &p;
printf("%d\n", [1]);
Drag options to blanks, or click blank then click option'
A*pp
Bpp
C**pp
D*p
Attempts:
3 left
💡 Hint
Common Mistakes
Using only one dereference *pp which gives pointer p, not value.
Using pp directly which is a pointer to pointer.
4fill in blank
hard

Fill both blanks to correctly change the value of x to 50 using pointer to pointer pp.

C
int x = 10;
int *p = &x;
int **pp = &p;
**pp = [1];
printf("%d\n", [2]);
Drag options to blanks, or click blank then click option'
A50
Bx
C**pp
D*p
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to assign value to *pp instead of **pp.
Printing **pp instead of *p.
5fill in blank
hard

Fill all three blanks to create a pointer to pointer, assign it, and print the value of x.

C
int x = 100;
int *p = &x;
int [1] = &p;
printf("%d\n", [2]);
Drag options to blanks, or click blank then click option'
A**pp
B*p
Dpp
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing pointer declaration syntax.
Using wrong dereference level when printing.