Program to check if a given number is even or odd using the function.

Here, we have a basic program example to check if the number is even or odd with functions using different languages. This program is created in c language, c++, Java, and Python.

Function to check if the number is eve or odd in C language

#include <stdio.h>
int isEven(int num)
{
    return !(num & 1);
}
int main()
{
    int num;
    printf("Enter any number: ");
    scanf("%d", &num);
    if(isEven(num))
    {
        printf("The number is even.");
    }
    else
    {
        printf("The number is odd.");
    }
    return 0;
}

Function to check if the number is eve or odd in C++ language

#include <iostream>
using namespace std;
int find_Oddeven(int);
int main()
{
    int num;
    cout << "Enter a number to ceck odd or even: ";
    cin>>num;
    find_Oddeven(num);
    return 0;
}
int find_Oddeven(int num){
if(num%2==0)
  cout<<num<<" is an even number";
else
    cout<<num<<" is an odd number";
}

Function to check if the number is eve or odd in Python language

def check(n):
    if (n < 2):
        return (n % 2 == 0)
    return (check(n - 2))
n=int(input("Enter number: "))
if(check(n)==True):
      print("Number is even!")
else:
      print("Number is odd!")

Function to check if the number is eve or odd in Java language

import java.util.Scanner;
class EvenOdd
 {
   public static void main (String args[])
    {
      Scanner scan=new Scanner(System.in);
      System.out.print("Enter the number to check for odd or even: ");
      int num=scan.nextInt();
      find_Oddeven(num);
     }
  static void find_Oddeven(int num)
     {
      if(num%2==0)
        System.out.println(num+" is even");
      else
        System.out.println(num+" is odd");
     }
}