It’s not the same. Try num = -79, and you will get different results from both operations. (-79) % 256 = -79, while (-79) & 0xff is some positive number.
Using unsigned int, the operations are the same, and the code will likely be the same.
PS- Someone commented
They shouldn’t be the same,
a % bis defined asa - b * floor (a / b).
That’s not how it is defined in C, C++, Objective-C (ie all the languages where the code in the question would compile).