-5

A function which inputs two unsigned integers a and b and finds whether the lowest byte of b appears exactly as it is in a (starting at any position) or not. ex:

    Enter a:53
    Enter b:13
    Binary of b: 00000000 00000000 00000000 00001101
    Binary of a: 00000000 00000000 00000000 00110101
    Yes, lowest byte of b appears in a.

GUYS this is my home work but i cant do it pls help me thank you for your helping

Bhuvanesh
  • 1,269
  • 1
  • 15
  • 25
Kont Dooku
  • 48
  • 2
  • 12
  • 1
    You shouldn't be posting homework here - how about telling us what you've tried, and what doesn't work, and maybe we can help point you in the right direction – Paradise Mar 20 '15 at 08:55
  • 2
    This is not what would normally be called "binary search". – interjay Mar 20 '15 at 08:55
  • 1
    This is off-topic asking for 'Please do my homework' and doesn't belong on SO – Matt Ko Mar 20 '15 at 08:55
  • i'm new.i dont know exactly what i do – Kont Dooku Mar 20 '15 at 08:58
  • 2
    Look up the `>>` (shift right) and `&` (bitwise and) operators. – interjay Mar 20 '15 at 08:59
  • 1
    @KontDooku Please try adding any code that you have tried to use to solve this yourself already. SO is not a homework completion service, you need to show that you have put in some effort yourself already and what point you are stuck at in particular. – Toby Mar 20 '15 at 11:00

1 Answers1

1

Here is some pseudo-code to get you started:

found = FALSE
for shift = 0 to 24
    if least significant byte of a == least significant byte of b then
        found = TRUE
        break
    endif
    shift a right by 1 bit
endfor

Now all you have to do is turn this into C code.

Paul R
  • 208,748
  • 37
  • 389
  • 560