Hi all, Im new to pelles c and i have to translate my pseudocode to c for a uni assignment. Just wondering how you translate the mod function (pseudocode) into something in c to determine whether a number is odd or even?
Use the modulo operator as defined by the ANSI C standard.
There's another trick you can use that's easier than the mod function (%)...
Integers are stored as binary values thus, every other value has the low order bit set to 1...
So you can use ... odd = x & 1 ... to test for odd and even.
For a quick reference to C's special characters...
Help -> Contents -> C Language Reference -> Expressions and Assignments -> Operator Precidence
You might want to mark the page in your help favorites.