easy
0 views

Odd or Even

Determine if a given integer is odd or even and print the result.

Understand the Problem

Problem Statement

Given an integer N, the program must determine whether it is Odd or Even and print the result.

An integer is Even if it is divisible by 2, otherwise it is Odd.

Constraints

  • 1 ≤ N ≤ 10⁹ (standard integer range)
  • N is a non-negative integer
  • The program must output exactly "Odd" or "Even" (case-sensitive)

Examples

Example 1
Input
5
Output
Odd
Explanation

Since 5 is not divisible by 2 (5 % 2 = 1), it is an odd number.

Example 2
Input
102
Output
Even
Explanation

Since 102 is divisible by 2 (102 % 2 = 0), it is an even number.

Solution

#include <stdio.h>

int main() {
    int N;
    scanf("%d", &N);
    
    if (N % 2 == 0) {
        printf("Even\n");
    } else {
        printf("Odd\n");
    }
    
    return 0;
}
Time:O(1)
Space:O(1)
Approach:

Step-by-step explanation:

  1. Include the standard input/output header file
  2. Declare integer variable N to store the input
  3. Read the integer from standard input using scanf
  4. Use modulo operator to check if N is divisible by 2
  5. If N % 2 equals 0, print "Even"; otherwise print "Odd"
  6. Return 0 to indicate successful execution

Visual Explanation

Loading diagram...