Search for question
Question

8. Complete the following C function, which will return true (1) when its parameter's 6th, 7th, and 9th least significant bits are 1, 0, and 1, respectively; and will return false (0) otherwise. That is, given an integer parameter whose value expressed in binary is 1x01xxxxx, the function will return return true regardless of the value of the bits in positions marked with an x. = 1011112 and For example, detectBit Pattern (943) should return true, because 94310 = 11101011112, which has a 1 in the 6th least significant bit, a 0 in the 7th least significant bit, and a 1 in the 9th least significant bit. For another example, detectBitPattern (47) should return false, because 4710: even though there is a 1 in the 6th least significant bit, the other conditions are not met. unsigned int detect BitPattern (unsigned int x) { } return YOUR CODE HERE; Your solution should be one line. Submit your answer in a plain text file named hw2.txt. Number your answer with the question number. Use only the C/C++ bit-twiddling operators &, 1, ^, and ~, as well as the shift operators << and >>. For this question, in addition to the bit-twiddling and shift operators, you may also use the comparison operators == and !=. Note that these operators return 1 for true and 0 for false. Hint: to solve this, you need only one & and one ==

Fig: 1