Question 1: Write an algorithm which returns 1 if the number is even and returns 0 if the number is odd.
Algorithm: CheckNum(n)
Requires: an integer n
Returns: 1 if n is even and 0 if n is odd.
1. if (n mod 2 == 0) then
2. return 1
3. else
4. return 0
5. endif
Question 2: Write an algorithm to implement the logical operator XOR.
Algorithm: XOR(a, b)
Requires: two boolean variables a and b.
Returns: a boolean value
1. if (a == b) then
2. return false
3. else
4. return true
5. endif