Using C Bitwise Operators in a Referendum - Homework -


I am doing a homework project and I am incredibly lost. Essentially, I have to create a function called majority which takes 3 short integers, and moves to the second number depending on the input. I give an example from this project:

Actually, I return the function majority (101010101010101, 101010101010101, 101010101010101), and if it has 2 or more 1, return 1, and return 0.

So far, I have

  low majority (small A, small B, small) {return (a | b | c)); }   

Now, I know that this is not correct Absolutely , so I'm asking here: How will I go about doing this? Thanks for the help, and I apologize if I am able to edit it, it is difficult to comply.

If I understand you correctly, then you want to set a result in a whole number if And only then the response bits are set to two or three input integers.

... This is because the bit is set to the first number and the corresponding bit has been set to any of the previous two numbers or related bit is set in both previous two numbers, so In a bit wise expression:

  result = (another (bc)). (B & C);    

Comments