Exercise 2: Checking for odd numbers
One obvious way to check for odd numbers in C
int isOdd(int n) { return (n%2) == 1; }
|
Could we use & to achieve the same thing? How?
Aside: an alternative to the above
#define isOdd(n) ((n)%2) == 1)
|
What's the difference between the function and the macro?
|