Alyssa R.

asked • 06/10/20

Computer coding ex question

  1. Refer to the loop starting at line 003. If the function is called with a 2 digit decimal number, how many times will the while loop execute?

001 unsigned int bitCount (int value) {

002 unsigned int count = 0;

003   while (value > 0) { / / until all bits are zero

004 if ( ( value & 1) == 1) { / / check lower bit

005 count++;

006 }

007 value >> 1; / / shift bits, removing lower bit

008   }

009   return count;

010 }


  1. Infinite
  2. 1
  3. 2
  4. At least 4


1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.