Javatpoint Logo
Javatpoint Logo

C++ bitset count() Function

C++ bitset count() function is used to count the number of set bits in the binary representation of a number.

Syntax

Parameter

It does not take any parameter.

Return value

It returns the number of set bits in an integer value.

Example 1

Output:

1100 has 2 bits

Example 2

Output:

0000 has 0 set bits
0010 has 1 set bits
Next TopicC++ bitset



Help Others, Please Share

facebook twitter pinterest