ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
how do u find out the number of 1's in the binary 
representation of a decimal number without converting it 
into binary(i mean without dividing by 2 and finding out 
the remainder)? three lines of c code s there it 
seems...can anyone help
 Question Submitted By :: Uttejana
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how do u find out the number of 1's in the binary representation of a decimal number without converting it into binary(i mean without dividing by 2 and finding out the remainder)? three lines of c code s there it seems...can anyone help
Answer
# 1
int x =0x1;
static count;
while(no ! =0)
{
 if((no >>1 & x) ==1)
count+=1;
}
printf("%d",count);
 
Is This Answer Correct ?    2 Yes 0 No
Barun
 
  Re: how do u find out the number of 1's in the binary representation of a decimal number without converting it into binary(i mean without dividing by 2 and finding out the remainder)? three lines of c code s there it seems...can anyone help
Answer
# 2
unsigned int count=0,no;
/* 
Enter no Here................
*/
while(no ! =0)
{
  if((no & 0x01) ==1)
     count++;
  no=no >>1
}
printf("%d",count);
 
Is This Answer Correct ?    6 Yes 0 No
Ravi Saini
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Reverse a string word by word??  6
how we can make 3d venturing graphics on outer interface Microsoft1
what type of language is C? Microsoft2
Whats wrong with the following function char *string() { char *text[20]; strcpy(text,"Hello world"); return text; } Qualcomm3
pointer_variable=(typecasting datatype*)malloc(sizeof(datatype)); This is the syntax for malloc?Please explain this,how it work with an example? Excel2
what is the use of pointers  5
What is the memory allocated by the following definition ? int (*x)(); ADITI2
what's the return value of malloc()  8
what is diff b/w huge & far & near pointer?? HCL1
Define function ?Explain about arguments? Geometric-Software2
If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.  4
when will be evaluated as true/ if(x==x==x) a) x=1; b) x=0; c) x=-1; d) none HCL4
What is the difference between null pointer and void pointer CTS3
What should be keep precautions while using the recursion method?  1
write a C code to reverse a string using a recursive function, without swapping or using an extra memory. Motorola2
what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }  3
a C prog to swap 2 no.s without using variables just an array? TCS4
what is the difference between arrays and linked list Tech-Mahindra15
what is the maximum limit of row and column of a matrix in c programming. in linux .  1
What is the meaning When we write "#include" what is # and what does include does there??? HCL11
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com