what is the purpose of the code, and is there any problem
with the code?

int f( int n, int l, int r )
{ return (n << l) >> r; }

Answer Posted / senthil

f returns (n * 2^(l-r))

n<<l => n * 2^l
(n<<l)>>r => (n * 2^l)/(2^r)=>(n * 2^(l-r))

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a null string in c?

583


What is use of integral promotions in c?

662


What are conditional operators in C?

619


The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference

669


What is the function of multilevel pointer in c?

668






Tell us bitwise shift operators?

592


What is sorting in c plus plus?

562


Where are the auto variables stored?

622


Can true be a variable name in c?

555


Explain what are multidimensional arrays?

596


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3180


Why is c still so popular?

614


Can a program have two main functions?

567


Dont ansi function prototypes render lint obsolete?

601


What is difference between Structure and Unions?

634