write a program to find out number of on bits in a number?
Answer Posted / kavitha
int setbit=1; //Lets start checking from first bit
int numBitSet=0; //Number of bits set in the number
while(setbit>0)
{
if(number&setbit) //bit wise and
numBitSet++;
setbit=setbit<<1;
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
What is the difference between int main and void main?
Can you subtract pointers from each other? Why would you?
What are the ways to a null pointer can use in c programming language?
If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.
What is the significance of an algorithm to C programming?
Is c# a good language?
What is the easiest sorting method to use?
Do you know the difference between exit() and _exit() function in c?
What is wrong in this statement?
What is the process of writing the null pointer?
What is difference between union and structure in c?
How do you initialize pointer variables?
Why do we use static in c?
Explain how can a program be made to print the name of a source file where an error occurs?