Programming Practice

Enter variable x as a 32-bit unsigned integer x31x30¼x1x0. Then enter a character 'R' or 'L' to indicate right rotation or left rotation and an integer between 0 and 32 (including) for the number of bits to be rotated. Write C a program to print x before and after the rotation operation.

Input an eight-digit hexadecimal number: 0XABCDEF12
Enter character 'r' for right rotation , 'l' for left rotation: R
Enter the number of bits to be rotated (0 to 32): 4


The input data is 0XABCDEF12. Right rotation 4 bits, the result is 0X2ABCDEF1.

-------------------------------------------------

Input an eight-digit hexadecimal number: 0X01234567
Enter character 'r' for right rotation , 'l' for left rotation: L
Enter the number of bits to be rotated (0 to 32): 12


The input data is 0X01234567. Left rotation 12 bits, the result is 0X34567012.

-------------------------------------------------

Input an eight-digit hexadecimal number: 0X0
Enter character 'r' for right rotation , 'l' for left rotation: R
Enter the number of bits to be rotated (0 to 32): 4


The input data is 0X00000000. Right rotation 4 bits, the result is 0X00000000.

-------------------------------------------------