Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 07 / bitwiseSimpleExamples.cpp
diff options
context:
space:
mode:
1 files changed, 16 insertions, 0 deletions
-rw-r--r--Sem. 07/bitwiseSimpleExamples.cpp16
diff --git a/Sem. 07/bitwiseSimpleExamples.cpp b/Sem. 07/bitwiseSimpleExamples.cpp
new file mode 100644
index 0000000..77e46b1
--- /dev/null
+++ b/Sem. 07/bitwiseSimpleExamples.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+using namespace std;
+
+bool isEven(int n)
+{
+ return !(n & 1);
+}
+
+unsigned powerOfTwo(unsigned n)
+{
+ return (1 << n);
+}
+int main()
+{
+ cout << powerOfTwo(8); // 2^8
+}