Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Even or Odd

1 topic · 28 Nov 2026
1

Even or Odd

Problem Solving

A number is even if it is divisible by 2 (n % 2 == 0), otherwise it is odd.

Solution 1: Modulus · C++
int n = 7;
if(n % 2 == 0) cout << "Even";
else cout << "Odd";
Solution 2: Bitwise AND (faster) · C++
// The last bit of an odd number is always 1
if(n & 1) cout << "Odd";
else cout << "Even";