Code:
if ((RED & mask) == 1)
if ((BLUE & mask) == 1)
if ((GREEN & mask) == 1)
if ((BLACK & mask) == 1)
if ((YELLOW & mask) == 1)
Only two of those comparisons will ever possibly evaluate to true: RED and GREEN. If you pass RED into the function, I'll bet it prints RED and GREEN. You need to reconsider your comparison strategy there (after you fix the accidental octal notation you used).
What you are doing (in binary):
Code:
0001 (red)
OR 0010 (blue)
----
0011 (green)
so 'mask' == 0011
0011 (mask)
AND 0011 (green)
----
0011
so (GREEN & mask) == 0011
What are you comparing it against....??