previous | start | next

Challenge Function

Write the function

 /**
  * Computes x / 2 (integer division)
  * Examples: div2( 6,2) =  3
  *           div2( 5,2) =  2
  *           div2(-6,2) = -3
  *           div2(-5,2) = -2
  * Restrictions: Use only int constants that fit in 1 byte
  *               Use only << >> & +
  * Max operators: 12
  */
 int div2(int x)
 {
   return 2;
 }
   


previous | start | next