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


July 07, 2008 04:48:51 #1
 nair.midhun3   Member Since: July 2008    Total Comments: 1 

RE: bit wise operator
 
int one =0;//number of ones
int zero=0;//number of zeros
for(int i=0;i<16;i++)
if((x >> 1) & 1 == 1)  one++;
 else zero++;
     

 

Back To Question