Question: Write the function int count101(int n) that counts the number of occurrences of the bit pattern 101 in n. It should return the final count.
Write the function int count101(int n) that counts the number of occurrences of the bit pattern 101 in n.
It should return the final count. Variable n is 32 bits. Example: Suppose n is just 8 bits, say n=11010101, then the function would return 3.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
