Program to check whether a given number is even or odd.

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

Program to check if the number is even or odd in C language

#include <stdio.h>
void main()
{
    int num;

    printf("Enter a number : ");
    scanf("%d", &num);
    if (num % 2 == 0)
        printf("The number is even\n");
    else
        printf("The number is odd\n");
}

Program to check if the number is even or odd in C++ language

#include<iostream>
using namespace std;
int main(){
int num;

    cout<<"Enter a number : ";
    cin>>num;
    if (num % 2 == 0)
       cout<<"The number is even";
    else
       cout<<"The number is odd";
}

Program to check if the number is even or odd in Python language

num = int(input("Enter a number:  "))
if num % 2 == 0 :
    print("The number is even\n")
else:
    print("The number is odd\n")

Program to check if the number is even or odd in Java language

import java.util.*;
class check
 {
   public static void main(String[] args)
    {
      int num;
  
      Scanner s=new Scanner(System.in);
      System.out.println("Enter a number :");
      num = s.nextInt();
     if(num % 2 == 0){
       System.out.println("The number is even");
          }
     else {
      System.out.println("The number is odd");      
          }
}
}