Finish swap(a, b) so the two variables in main really swap. a and b are pointers that hold the addresses of x and y; *a is x itself. The program swaps two pairs and shows them: 3 8 becomes 8 3.
8 3 100 -1
#include <stdio.h>
void swap(int *a, int *b) {
// your code here: use a temp variable t to swap *a and *b
}
int main(void) {
int x = 3, y = 8;
int p = -1, q = 100;
swap(&x, &y);
swap(&p, &q);
printf("%d %d\n", x, y);
printf("%d %d\n", p, q);
return 0;
}
Run tries the examples. When they look right, Submit.