C Program to check whether the No. is Odd or Even.
Hello friends in this program we will determine whether the no is even or odd using C code. As you have study in mathematics that in decimal number system even numbers are divisible by 2 while odd are not so we may use modulus operator(%) which returns remainder, For example 4%3 gives 1 ( remainder when four is divided by three). Even numbers are of the form 2*p and odd are of the form (2*p+1) where p is is an integer.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter a no. \n");
scanf("%d",&n);
if(n%2==0)
printf("No. is even.\n");
else
printf("No. is odd\n");
getch();
}
No Comment to " C Program to check whether the No. is Odd or Even. "