You are required to write a MAL program that prompts a user for a positive decimal integer[ A positive integer is one that is strictly greater than zero.], reads the integer typed by the user and outputs the following values:
1.The total number of 1's in the right half of the binary representation of the integer.
2.The total number of 0's in the left half of the binary representation of the integer.
3.The highest power of 2 that evenly divides the integer[ An integer x evenly divides an integer y if the remainder when y is divided by x is zero.].
4.The value of the largest digit in the decimal representation of the integer.
Example: Suppose the user types the decimal integer 1536. The 32-bit binary representation of 1536 is as follows:
0000 0000 0000 0000 0000 0110 0000 0000
For this example, the required answers are as follows:
1.The number of 1's in the right half of the binary representation of the given integer = 2.
2.The number of 0's in the left half of the binary representation of the given integer = 16.
3.The largest power[ The largest power of 2 that evenly divides 1536 is 9 because 1536 = 3 * 512 = 3 * 2^9. This highest power is also the number of 0's at the end of the binary representation of 1536.] of 2 that evenly divides the given integer is 9.
4.The value of the largest digit in the decimal representation of the given integer = 6.
The outline for your program for Part (a) must be the following.
1.Prompt the user for a positive integer.
2.Read the integer.
3.Compute the four quantities mentioned above and print the answers.
1)Each time your program for Part (a) is executed, it should handle just one integer.
2)You may assume that the value typed by the user is a positive decimal integer. Thus, there is no need to do any error checking in this part.
3)There is no need to convert the integer to binary; when the integer is read in (using syscall), it is already in binary form.
4)Use bitwise operations to count the number of 1’s (0’s) in the right (left) half.
5)To find the highest power of 2 that divides the integer, count the number of 0’s at the end of the binary representation or use successive divisions by 2.
6)To extract the decimal digits and compute the largest digit, use successive divisions by 10.