A better solution is to use bitwise operators. We need to check whether last bit is 1 or not. If last bit is 1 then number is odd, otherwise always even.
input : 5 // odd
00000101
& 00000001
--------------
00000001
--------------
Check whether a given number is even or odd : https://www.geeksforgeeks.org/check-whether-given-number-even-odd/