ANSWERS TO EXERCISES ON POINTERS
1. None. Some people prefer A to indicate that *x is an int;
thus x is a pointer to an int. Others prefer B to indicate that
x is the variable being declared. Not many people use C; it was
just included to demonstrate that the position of the * is
irrelevant.
2. x = 5, y = 10. The function has no effect since integers are
passed by value. Variables a and b contain only local copies
of the integers 5 and 10.
3. x = 10, y = 5. Since the memory addresses of x and y are passed,
the function is able to correctly swap their values.
4. scanf() needs to change the value of n. A function cannot change the
value of an integer unless it knows its memory address. Instead
of passing the current value of n, we use &n to pass its memory address.