Odd or Even

The program must print if the given number is Odd or Even.

Example Input/Output 1:
Input:
5

Output:
Odd

Example Input/Output 2:
Input:
102

Output:
Even

Python

N = int(input())
if N & 1:
    print('Odd')
else:
    print('Even'))

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N % 2 == 0) {
            System.out.print("Even");
        } else {
            System.out.print("Odd");
        }
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int N;
    scanf("%d", &N);
    if(N & 1)
    {
        printf("Odd");
    }
    else
    {
        printf("Even");
    }
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    if(N%2 == 0)
    {
        cout << "Even";
    }
    else
    {
        cout << "Odd";
    }
    return 0;
}
Previous Article

Pass or Fail

Next Article

Atleast One Number 100

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *