A whole number is considered Odd if it cannot be evenly divided by two,
leaving a remainder of 1. Or, to put it another way, odd numbers cannot be
divided by two.
For example, 1, 3, 5, 7, and 9 are odd numbers.
A whole number divided by two without leaving a remainder is said to be
Even. Alternatively, even numbers are those that can be divided by two.
For
example, 0, 2, 4, 6, and 8 are all even numbers.
For example: –
57 is an Odd Number
Explanation: 57 % 2 = 1, thus 57 is an Odd Number
Explanation: 18 % 2
=0, thus 18 is an Even Number
18 is an Even Number
Be sure to check out the following codes and learn how to determine whether a number is odd or even!
C
#include <stdio.h>
void main()
{
int a;
printf("Enter a number : ");
scanf("%d",&a);
if(a%2!=0)
{
printf("%d is an Odd Number",a);
}
else
{
printf("%d is an Even Number",a);
}
}
C++
#include <iostream>
using namespace std;
main()
{
int a;
cout<<"Enter a number : ";
cin>>a;
if(a%2!=0)
{
cout<<a<<" is an Odd Number";
}
else
{
cout<<a<<" is an Even Number";
}
}
Java
import java.util.Scanner;
class OoE
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number : ");
int a=sc.nextInt();
sc.close();
if(a%2!=0)
{
System.out.println(a+" is a Odd Number");
}
else
{
System.out.println(a+" is a Even Number");
}
}
}
Python
a=int(input("Enter a number : "))
if a%2!=0:
print(a," is a Odd Number")
else:
print(a," is a Even Number")

0 Comments