To check whether the number is Even or Odd using if else
This Program checks whether the entered number is even or odd...
Any integer is input through the keyboard.
Write a program to find out whether it is an odd number or even number.
#include<stdio.h>
main()
{
int num;
printf ("Enter a number to be checked for even/odd: ");
scanf ("%d",&num);
if (num%2==0)
{
printf ("The entered number is EVEN.\n");
}
else
{
printf ("The entered number is ODD.\n");
}
}
The file can also be downloaded at:
Download File
Any integer is input through the keyboard.
Write a program to find out whether it is an odd number or even number.
#include<stdio.h>
main()
{
int num;
printf ("Enter a number to be checked for even/odd: ");
scanf ("%d",&num);
if (num%2==0)
{
printf ("The entered number is EVEN.\n");
}
else
{
printf ("The entered number is ODD.\n");
}
}
The file can also be downloaded at:
Download File
Comments
#include
void main()
{
int i;
clrscr();
printf("\n Input any number");
scanf("%d",&i);
if(i%2==0);
{
printf("\n Number is even");
}
else
{
printf("\n Number is odd");
}
getch();
}
main()
{
int n;
printf ("Enter a number: ");
scanf ("%d",&n);
(n%2==0 ? printf("Even no"):printf ("ODD no"));
}
we can do this by using condition operator
frac([number]/2)
that will return either 1 or 0 if the number is even or odd