An even number is an integer divisible by 2 with remainder 0. In math form: n = 2 * k for some integer k.
Remember
n is even ↔ n % 2 == 0
Examples:
10 % 2 == 0 → even
11 % 2 == 1 → odd
0 % 2 == 0 → even
-4 % 2 == 0 → even
n
n % 2
Result
10
0
Even
11
1
Odd
0
0
Even
-4
0
Even
Approach
How to Check an Even Number in C
Four clear steps — then pick modulo, bitwise, or a step-by-two range loop.
Read the integer n (positive, negative, or zero).
Compute n % 2 (or check the least significant bit with n & 1).
If the remainder is 0 (or the LSB is 0), n is even.
To list evens in a range, test each value — or start at the first even and add 2.
Method
Idea
Time
Best for
Modulo
n % 2 == 0
O(1)
Interviews, clearest logic
Bitwise
(n & 1) == 0
O(1)
Optional follow-up, LSB check
Step by 2
Start at first even, add 2
O(N/2)
Listing evens in a range
Pseudocode
Pseudocode
function IsEven(n):
return (n mod 2) == 0
function PrintEvens(start, end):
for i from start to end:
if IsEven(i):
output i
// Faster range listing:
function PrintEvensStep(start, end):
i = start
if i is odd:
i = i + 1
while i <= end:
output i
i = i + 2
Reference
Cheat Sheet
Keep these facts handy while writing the program.
Topic
Detail
Even test
n % 2 == 0
Odd test
n % 2 != 0
Bitwise even
(n & 1) == 0
Zero
0 is even
Negatives
-4 is even; -3 is odd
Classic check
10 → even; 11 → odd
Try it
Live Preview
Enter any integer to see the remainder and the even/odd verdict.
Whole numbers only. Tap a chip or type a value.
Result
n = 10
n % 2 = 0
(n & 1) = 0
Verdict: EVEN
Trace
Worked Walkthrough — n = 10
Apply the modulo rule, then confirm with the bitwise check.
Calculation
Step 1: Compute 10 % 2
10 = 2 * 5 + 0
remainder = 0
Step 2: Remainder is 0 → even
Step 3: Bitwise check
10 in binary ends with 0
(10 & 1) = 0 → same answer
Verdict: 10 is even
Code
C Programs
Start with the modulo helper — it is the clearest interview answer. Then reuse it for a range, and finish with the bitwise shortcut.
Example 1 — Modulo Check
Return true when the remainder by 2 is exactly zero.
C
#include <stdio.h>
int is_even(int n)
{
return n % 2 == 0;
}
int main(void)
{
int number = 10;
if (is_even(number))
printf("%d is an even number.\n", number);
else
printf("%d is not an even number.\n", number);
return 0;
}
Output
10 is an even number.
How It Works
is_even computes n % 2 and compares it with 0.
For 10, the remainder is 0, so the function returns true (nonzero).
main prints the matching message based on that result.
Swap 10 for 11 to see the odd path.
This is the default answer to give in interviews — clear and correct.
Example 2 — Evens in a Range
Reuse the helper to print every even value from 1 to 10.
C
#include <stdio.h>
int is_even(int n)
{
return n % 2 == 0;
}
int main(void)
{
int start = 1;
int end = 10;
int i;
printf("Even numbers from %d to %d:\n", start, end);
for (i = start; i <= end; i++)
{
if (is_even(i))
printf("%d ", i);
}
printf("\n");
return 0;
}
Output
Even numbers from 1 to 10:
2 4 6 8 10
How It Works
The loop runs from start to end inclusive (i <= end).
Each i is tested with is_even.
Only even values are printed: 2 4 6 8 10.
Odd values like 1, 3, and 5 are skipped.
For large ranges, start at the first even and use i += 2 instead of testing every integer.
Example 3 — Bitwise Check
Even integers have a least significant bit of 0, so n & 1 is 0.
C
#include <stdio.h>
int is_even_bitwise(int n)
{
return (n & 1) == 0;
}
int main(void)
{
int samples[] = { 10, 11, 0, -4 };
int i;
for (i = 0; i < 4; i++)
{
int n = samples[i];
printf("%d: %s\n", n, is_even_bitwise(n) ? "even" : "odd");
}
return 0;
}
Output
10: even
11: odd
0: even
-4: even
How It Works
n & 1 keeps only the least significant bit.
If that bit is 0, the number is even; if 1, it is odd.
The sample array shows positives, zero, and a negative even value.
Results match the modulo method for these integers.
Prefer modulo in interviews for readability; mention bitwise as a follow-up.
Edge Cases & Pitfalls
Check these before calling the solution done.
Zero
0 is even
0 % 2 == 0. Do not special-case zero as “neither.”
Negatives
Parity still applies
-4 is even. Odd negatives can give -1 with % — still nonzero, so still odd.
Floats
Use integers
Even/odd is defined for integers. Do not apply % 2 to floating-point “counts” without a clear rule.
Range
Inclusive bounds
Use i <= end when both ends should be checked. Off-by-one errors drop the last even.
Analysis
Time and Space Complexity
Program
Time
Extra space
Modulo / bitwise check
O(1)
O(1)
Scan range of size N
O(N)
O(1)
Step-by-two listing
O(N/2)
O(1)
A single parity test is constant time. Range printers grow with how many integers you visit.
Remember
Key Takeaways
Definition: divisible by 2 with remainder 0 (n = 2k).
Default test:n % 2 == 0.
Bitwise option:(n & 1) == 0.
Test set: 10 even; 11 odd; 0 even; −4 even.
One line: if n % 2 == 0, the integer is even — including zero and many negatives.
Frequently Asked Questions
An integer n is even if n = 2 * k for some integer k. Equivalently, n is divisible by 2 with remainder 0.
Use n % 2 == 0 for the clearest test. You can also use (n & 1) == 0 as a bitwise shortcut.
Yes. 0 = 2 * 0, so 0 % 2 == 0 and zero is even.
Yes. -4 is even. In C (C99+), -4 % 2 == 0. Prefer (n & 1) == 0 if you want one rule that also avoids odd-negative remainder quirks.
Checking one number is O(1). Scanning a range of size N is O(N), or O(N/2) if you start at the first even and step by 2.