Loading...
Engaged Employer
Write a function that takes an integer and counts the number of bits.
Anonymous
This is a simple bit manipulation problem. If you study before your interviews, this is a common area to study.
void count_Bits(int inp){ int count = 0; for (int y = inp; y >=1;y = y /2 ){ count++; } cout<< "number of bits : " << count<< endl; }
If you take a simple log base 2 of the integer, that should give you the number of bits, right?
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.