MCQs > IT & Programming > Programming With C > What does the following function do? int fn(unsigned int x) { int count = 0; for(; x!=0; x&=(x-1)) count++; return count; }

Programming With C MCQs

What does the following function do?
int fn(unsigned int x)
{
        int count = 0;
        for(; x!=0; x&=(x-1))
                count++;
        return count;
}

Answer

Correct Answer: Returns the number of 1 bits(bits having one) in the number x

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Programming With C Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Programming With C Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it