Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions BitMasking
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
https://www.geeksforgeeks.org/bits-manipulation-important-tactics/

Theory from tutorials point
Program 1:

#include <iostream>
#include <bitset>

using namespace std;

int main(void) {

bitset<4> b;

cout << "Before set operation b = " << b << endl;

b.set();

cout << "After set operation b = " << b << endl;

return 0;
}
Let us compile and run the above program, this will produce the following result −

output:
Before set operation b = 0000
After set operation b = 1111


Program2:
#include <iostream>
#include <bitset>

using namespace std;

int main(void) {

bitset<4> b("1110");

cout << "In bitset " << b << ", " << b.count() << " bits are set." << endl;

return 0;
}
Let us compile and run the above program, this will produce the following result −

output:
In bitset 1110, 3 bits are set.
Empty file modified InsertionSort.cpp
100644 → 100755
Empty file.
Empty file modified Linkedlist
100644 → 100755
Empty file.
Empty file modified MergeSort.cpp
100644 → 100755
Empty file.
Empty file modified N-Queen.cpp
100644 → 100755
Empty file.
Empty file modified Prims.cpp
100644 → 100755
Empty file.
Empty file modified QuickSort.cpp
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified SelectionSort.cpp
100644 → 100755
Empty file.