Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a pointer to an integer.
C
int [1] ptr; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of * to declare a pointer.
Forgetting the * symbol entirely.
✗ Incorrect
The asterisk (*) is used to declare a pointer variable in C.
2fill in blank
mediumComplete the code to declare a pointer to a character.
C
char [1] ch_ptr; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of * for pointer declaration.
Using symbols like ^ or $ which are invalid here.
✗ Incorrect
The asterisk (*) is used to declare a pointer variable, here pointing to a char.
3fill in blank
hardFix the error in the pointer declaration.
C
float [1] ptr; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Placing & instead of *.
Using invalid symbols like # or @.
✗ Incorrect
The asterisk (*) must be placed before the pointer variable name to declare a pointer.
4fill in blank
hardFill both blanks to declare a pointer to a double and initialize it to NULL.
C
double [1] ptr = [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of NULL for pointer initialization.
Using & instead of * for pointer declaration.
✗ Incorrect
The asterisk (*) declares the pointer, and NULL initializes it to point to nothing.
5fill in blank
hardFill all three blanks to declare a pointer to a constant integer and initialize it to NULL.
C
const int [1] ptr = [2]; // pointer to constant int [3] value = 10;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using & instead of * for pointer declaration.
Using wrong variable type for value.
Initializing pointer with 0 instead of NULL.
✗ Incorrect
The asterisk (*) declares the pointer, NULL initializes it, and int declares the variable type.