bitset reset() function in C++ STL Last Updated : 18 Jun, 2018 Comments Improve Suggest changes Like Article Like Report bitset::reset() is a built-in function in C++ STL which resets the bits at the given index in the parameter. If no parameter is passed then all the bits are reset to zero. Syntax: reset(int index) Parameter: The function accepts a parameter index which signifies the position at which the bit has to be reset to zero. If no parameter is passed, all the bits in the bitset are reset to zero. Return Value: The function does not return anything. Below programs illustrates the bitset::reset() function. Program 1: CPP // CPP program to illustrate the // bitset::reset() function #include <bits/stdc++.h> using namespace std; int main() { // Initialization of bitset bitset<4> b1(string("1100")); bitset<6> b2(string("111111")); // Function that resets all bits cout << "Before applying reset() function: " << b1 << endl; b1.reset(); cout << "After applying reset() function: " << b1 << endl; // Function that resets all bits cout << "Before applying reset() function: " << b2 << endl; b2.reset(); cout << "After applying reset() function: " << b2 << endl; return 0; } Output: Before applying reset() function: 1100 After applying reset() function: 0000 Before applying reset() function: 111111 After applying reset() function: 000000 Program 2: CPP // CPP program to illustrate the // bitset::reset() function #include <bits/stdc++.h> using namespace std; int main() { // Initialization of bitset bitset<4> b1(string("1101")); bitset<6> b2(string("111111")); // Function that resets all bits cout << "Before applying reset() function: " << b1 << endl; b1.reset(2); cout << "After applying reset(2) function: " << b1 << endl; // Function that resets all bits cout << "Before applying reset() function: " << b2 << endl; b2.reset(3); b2.reset(5); cout << "After applying reset(3) and reset(5) function: " << b2 << endl; return 0; } Output: Before applying reset() function: 1101 After applying reset(2) function: 1001 Before applying reset() function: 111111 After applying reset(3) and reset(5) function: 010111 Comment More infoAdvertise with us Next Article bitset reset() function in C++ STL G gopaldave Follow Improve Article Tags : Misc C++ STL CPP-Functions CPP-bitset +1 More Practice Tags : CPPMiscSTL Similar Reads bitset set() function in C++ STL bitset::set() is a built-in STL in C++ which sets the bit to a given value at a particular index. If no parameter is passed, it sets all bits to 1. If only a single parameter is passed, it sets the bit at that particular index to 1. Syntax: set(int index, bool val) Parameter: The function accepts tw 2 min read bitset all() function in C++ STL The bitset::all() is a built-in function in C++ STL which returns True if all bits are set in the binary representation of a number if it is initialized in the bitset. It returns False if all the bits are not set. Syntax: bool bitset_name.all() Parameter: This function does not accepts any parameter 2 min read Counting Set Bits in C++ Counting set bits means determining how many bits in a binary representation of a number are set to 1.ExampleInput: n = 103 (01100111)Output: 5Explanation: The binary representation of 103 is 01100111. Hence, the number of set bits is 5.Input: n = 15 (1111)Output: 4Explanation: The binary representa 4 min read bitset::flip() in C++ STL bitset::flip() is a built-in STL in C++ which flips the bits. If no parameter is passed in the function, then it flips all the bit values converting zeros to ones and ones to zeros. If a parameter position is passed, it flips the bit at the position only. Syntax: bitset_name.flip(int pos) Parameter: 2 min read bitset none() in C++ STL bitset::none() is a built-in STL in C++ which returns True if none of its bits are set. It returns False if a minimum of one bit is set. Syntax: bool none() Parameter: The function accepts no parameter. Return Value: The function returns a boolean. The boolean value is True if none of its bits are s 2 min read Like