Test your understanding of the & operator, * operator, NULL pointers, and the swap function.
int a = 42; int *p = &a; printf("%d\n", *p);
p holds the address of a. *p dereferences the pointer to fetch the value at that address — the value of a, which is 42.int a = 10; int *p = &a; *p = 20; printf("a = %d\n", a);
*p = 20 writes 20 to the location p points to (which is a). The value of a changes, so a = 20.int *p = NULL; printf("%d\n", *p);
*p) is undefined behavior.void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; } int main(void) { int x = 3, y = 7; swap(&x, &y); printf("x=%d, y=%d\n", x, y); return 0; }
*a = x, *b = y: tmp=3, *a=7, *b=3.