Skip to content

Commit d1f218b

Browse files
committed
added usage
1 parent b2caf4e commit d1f218b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: cpp, number, bitwise, even, odd
3-
description : This code demonstrates the fastest way to check if a number is even or odd using bitwise operations. It's more efficient than using the modulor operator (%) since bitwise operations are performed at the CPU level.
4-
tags : cpp, number, even, odd, bitwise
5-
author : Beast177
3+
description: This code demonstrates the fastest way to check if a number is even or odd using bitwise operations. It's more efficient than using the modulor operator (%) since bitwise operations are performed at the CPU level.
4+
tags: cpp, number, even, odd, bitwise
5+
author: Beast177
66
---
77

88
```cpp
@@ -11,5 +11,18 @@ bool isEven(int num) {
1111
return !(num & 1);
1212
}
1313

14+
// usage -- [odd-even]
15+
16+
#include <iostream>
17+
18+
int main(){
19+
20+
int num1 = 2;
21+
int num2 = 3;
22+
23+
std::cout << num1 << " is " << (isEven(num1) ? "Even" : "Odd") << "\n"; // output - [Even]
24+
std::cout << num2 << " is " << (isEven(num2) ? "Even" : "Odd") << "\n"; // output - [Odd]
25+
}
26+
1427
```
1528

0 commit comments

Comments
 (0)