Related Articles
_Find_first() function in C++ bitset with Examples
• Last Updated : 03 Dec, 2019

The _Find_first() is a built-in function in C++ Biteset class which returns an integer that refers the position of first set bit in bitset. If there isn’t any set bit, _Find_first() will return the size of the bitset.

Syntax:

```iterator bitset._Find_first()
or
int bitset._Find_first()
```

Parameters: The function accepts no parameter.

Return Value: The function returns an integer which refers to the position of first set bit in bitset. If there isn’t any set bit, _Find_first() will return the size of the bitset.

Below is the illustration of the above function:

 `// C++ program for illustration``// of _Find_first() function`` ` `#include ``using` `namespace` `std;`` ` `#define M 32`` ` `int` `main()``{``    ``// default constructor initializes with all bits 0``    ``bitset bset;``    ``bitset bset1;`` ` `    ``// 00000000000000000000000000100000``    ``bset = 1;`` ` `    ``// 00000000000000000000010000100000``    ``bset = 1;`` ` `    ``// function returns the first set bit in Bitset``    ``cout << ``"position of first set bit in bset\n"``;``    ``cout << bset._Find_first() << ``"\n"``;`` ` `    ``// function returns bset1.size()``    ``// when no bit is set in bitset.``    ``cout << ``"position of first set bit in bset1\n"``;``    ``cout << bset1._Find_first() << ``"\n"``;`` ` `    ``return` `0;``}`
Output:
```position of first set bit in bset
5
position of first set bit in bset1
32
```
Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up