Javatpoint Logo
Javatpoint Logo

C++ bitset test() Function

C++ bitset test() function is used to test whether the bit at position p is set or not. If bit is set at position p then it returns true or false.

Syntax

Parameter

p: It takes one parameter and it specifies the index at which the bit is set or not.

Return value

It returns true if the bit at position p is set, and false if it is not set.

Example 1

Output:

bitset b is set at position 3 : 0
 bitset b is set at position 2 : 1

Example 2

Output:

bitset b is set at position 3 : 0
bitset b1 is set at position 2 : 1

Example 3

Output:

bitset is set at postion 1
Next TopicC++ bitset



Help Others, Please Share

facebook twitter pinterest