Question
Write a function circular_shift() that takes as arguments an integer a and an unsigned integer pos, and returns the integer obtained from a by performing
Write a function circular_shift() that takes as arguments an integer a and an unsigned integer pos, and returns the integer obtained from a by performing a circular left-shift of its bits by pos positions. Unlike the C left shift operator, which drops the high order bits, the circular left shift must insert the high order bits as the low order bits of the result.
For example:
Test Result
printf("%d", circular_shift(1,1) ); 2
printf("%d", circular_shift(1,10) ); 1024
printf("%d", circular_shift(1,1024) ); 1
int circular_shift(int a, int pos) { // TODO }
Write a function circular_shift() that takes as arguments an integer a and an unsigned integer pos, and returns the integer obtained from a by performing a circular left-shift of its bits by pos positions. Unlike the C left shift operator, which drops the high order bits, the circular left shift must insert the high order bits as the low order bits of the result. For example: Test Result 2 printf("%d", circular_shift(1,1) ); printf("%d", circular_shift(1,10) ); 1024 printf("%d", circular_shift(1,1024) ); 1 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started