Complete the code to declare a pointer to an integer.
int [1] ptr;The asterisk (*) is used to declare a pointer variable in C.
Complete the code to assign the address of variable x to pointer p.
int x = 10; int *p; p = [1]x;
The & operator gives the address of a variable, which can be assigned to a pointer.
Fix the error in the code to correctly access the value pointed by p.
int x = 5; int *p = &x; int y = [1];
The * operator is used to dereference a pointer and access the value it points to.
Fill both blanks to create a pointer to an array and access its first element.
int arr[3] = {1, 2, 3}; int [1] p = arr; int first = [2];
Declaring *p makes p a pointer. Accessing p[0] gets the first element of the array.
Fill all three blanks to correctly allocate memory, assign value, and free it.
#include <stdlib.h> int *p = (int*)[1](sizeof(int)); *p = [2]; [3](p);
malloc allocates memory, 42 is assigned to the allocated space, and free releases the memory.
