# solution

• Write a complete program with a function (and at least three tests of the function) that changes the trailing three bits for 101.

• The functions must not contain arrays.

1. Write a function equalReverseThirdBits (and at least three tests of the function) which returns 1 if the binary representations of the left and right thirds of its parameter are equal when reversed, and 0 otherwise. For example, The function must return 1 when the input is 0b101 because the left (1) and right thirds (1) are equal when reversed. It also returns 1 when the input is 0b10001.

2. Create a complete program with a function (and at least three tests of the function) that counts how many pair of bits are “10” given some int value.

3. Write a function named compareActiveSequences (and at least three tests of the function) that accepts two int arguments a and b, and compares the length of sequences of active bits (number of 1s) between them. It returns -1 if the bitwise representation of the first parameter has fewer 1s in the largest active sequence than the largest active sequence of the second parameter. It returns 1 if the bitwise representation of the sencond parameter has fewer 1s in the largest active sequence than the largest active sequence of the first parameter. It returns 0 otherwise. For example, the function returns -1 when inputting the parameters 0b1101110 and 0b11110111.
4. Write a function reverseSubChain(targetValue, bitsCount, position) (and at least three tests of the function) that returns the value of targetValue with the bitsCount that begins at position in reversed state. For example, reverseSubChain(0b100110, 4, 3) must return 0b0010110.

5. Create a program with a function (and at least three tests of the function) that shifts bits of a 64-bits integer to the left in a circular fashion. This is, the most significant bit will be now the less significant bit; while the less significant bit moves to the second less significant place. Assume that the number to be shifted has 64 bits.

6. Create a program with a function (and at least three tests of the function) that shifts bits of a 64-bits integer to the right in a circular fashion. This is, the less significant bit will be now the most significant bit; while the most significant bit moves to the second most significant place. Assume that the number to be shifted has 64 bits.

7. Create a function (and at least three tests of the function) that swaps bits in a given position, for example, swapBits64(10, 3, 0) will swap the values of the bit 3 (from right to left) with the value of the most significant bit in a 64-bits integer.