GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  OOPS

 Print  |  
Question:  bit wise operator

Answer: in a given number how many 1 bits and 0 bits are there,,,,,,,,,,can anyone solve this problem by using bit wise operator


June 06, 2009 10:03:28 #2
 sharan327   Member Since: March 2009    Total Comments: 1 

RE: bit wise operator
 
for(int count = 0; ;n = n>>1)
{
     count += (n&1);
}
     

 

Back To Question