Check the given number is ODD or EVEN.
The number is even only if number divided by 2 and the remainder is 0.
#include<stido.h>
#include<conio.h>
main()
{
int num;
printf(" Enter any number :- ");
scanf("%d",&num);
if(num%2==0)
{
printf(" The given number is Even");
}
else
{
printf("The given number is Odd");
}
getch();
}
Output:
1) Enter any number :- 8
The given number is Even
2) Ener any number:- 5
The given number is Odd
Explanation:
Note: % is a mod operator which return the remainder of the
division operator
1)Suppose the number is 8 then,
8 divide by 2 then remainder = 0, So the number is Even
2) The number is 5 then,
5 divide by 2 then remainder = 1, The number is Odd
For more program and notes please follow the link
You can see
Program to check the given number is positive or negative
program for sum of digit
0 comments:
Post a Comment