Task: Binary Even and Hexadecimal Odd
You will solve the exercise starting from the file odd_even.c
located in the directory tasks/odd-even/
.
Traverse an array of 32-bit integers using pointer operations and display the even numbers in binary and the odd numbers in hexadecimal.
NOTE: Use bitwise operations wherever possible in your solution!
NOTE: For the array
[214, 77, 84, 134, 86]
, the program will display:0b11010110 0x0000004D 0b01010100 0b10000110 0b01010110
Use capital letters when printing hexadecimal numbers (use the
%08X
format string forprintf()
).
To test the implementation, enter the tests/
directory and run:
make check
In case of a correct solution, you will get an output such as:
./run_all_tests.sh
test_small_array ........................ passed ... 33
test_medium_array ........................ passed ... 33
test_big_array ........................ passed ... 34
Total: 100/100
If you’re having difficulties solving this exercise, go through this reading material.