text: Count total bits in a number | Function to get no of bits in binary representation of positive integer ; Driver program
code: #include <stdio.h> NEW_LINE unsigned int countBits ( unsigned int n ) { unsigned int count = 0 ; while ( n ) { count ++ ; n >>= 1 ; } return count ; } int main ( ) { int i = 65 ; printf ( " % d " , countBits ( i ) ) ; return 0 ; }