EXERCISES ON POINTERS
1. What's the difference between the following declarations.
A. int *x;
B. int* x;
C. int * x;
2. Assume x = 5, y = 10. What are the values of x and y after calling swap1(x, y)?
void swap1(int a, int b) {
int t;
t = a; a = b; b = t;
}
3. Assume x = 5, y = 10. What are the values of x and y after calling
swap2(&x, &y)?
void swap2(int *pa, int *pb) {
int t;
t = *pa; *pa = *pb; *pb = t;
}
4. To print an integer n to standard output we use printf("%d", n), but to
read it in we use scanf("%d ", &n). Why is the & necessary with scanf()?