Showing posts with label Even Or Odd. Show all posts
Showing posts with label Even Or Odd. Show all posts

Wednesday, 13 May 2015

Python Program to find whether a number is EVEN or ODD

This is a basic program which checks whether the number is Even or Odd.

PROGRAM :
num = int(input('Enter a number: '))

if(num % 2 ==0):
    print(num , "is EVEN")
else:
    print(num , "is ODD")



OUTPUT : 
Python - Even or Odd

Python - Even or Odd



Similar Programs : 
C Program to find whether a number is EVEN or ODD
Cpp Program to find whether a number is EVEN or ODD
Java Program to find whether a number is EVEN or ODD

Monday, 12 January 2015

Cpp Program to find whether a number is even or odd

This is a basic Cpp program which checks whether the given number is even or odd.

Generally if a number is divisible by 2 then we call that number as an even number else it is an odd number.For checking whether a number is divisible by 2 we find the remainder of the given number when divided by 2.If the remainder is 0 we say that the number is EVEN else it is ODD.

PROGRAM :
#include <iostream>

using namespace std;

int main()
{
    int n;
    cout << "Enter any number : \t" ;
    cin  >> n ;

    if(n%2 == 0)
        cout  << n << " is EVEN number " << endl;
    else
        cout << n << " is ODD number " << endl;

    return 0;
}

OUTPUT : 
Cpp - Even Or Odd

Monday, 5 January 2015

Java Program to check whether a number is Even Or Odd


This is a basic java program which checks whether the given number is even or odd.

PROGRAM :


package codingcorner.in;

import java.util.Scanner;

public class EvenOrOdd {

 public static void main(String[] args) {

  Scanner scan = new Scanner(System.in);

  System.out.println("Enter any number");
  int number = scan.nextInt();

  scan.close();

  if (number % 2 == 0)
   System.out.println(number + " is EVEN number");
  else
   System.out.println(number + " is ODD number");

 }
}

OUTPUT :