Skip to main content

Command Palette

Search for a command to run...

Even odd Program

Updated
Even odd Program
M

IIIT - N Software Geek. Startup Enthusiast. Build for the Future.

Explanation:

If a number that is divisible by 2 and gives the reminder is 0 then it is called as the even number otherwise, it is a odd number.

ex1: suppose we take a number 10 and divided by 2 i.e, 10 / 2 which gives the reminder value is 0 so it is even number.

ex2: if we take the another number 15 and if that is divided by 2 that gives you the reminder as 1. so it is a odd number.

Java Code :

import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number = ");
        int number = sc.nextInt();
        if(number%2==0){
            System.out.println("Even number");
        }
        else{
            System.out.println("Odd Number");
        }

    }
}

C++ Code:

#include<iostream>
using namespace std;

int main(){
    int num;
    cout<<"Enter a number"<<endl;
    cin>>num;
    if(num % 2 == 0){
        cout<<"Even Number"<<endl;
    }
    else{
        cout<<"Odd Number"<<endl;
    }
}

Python code:

num = int(input("Enter a number = "))
if num % 2 ==0:
    print("Even number")
else:
    print("Odd Number")

More from this blog