Even:
Any integer that can be divided exactly by 2 is an even number.
The last digit is 0, 2, 4, 6 or 8
Odd:
Any integer that cannot be divided exactly by 2 is an odd number.
The last digit is 1, 3, 5, 7 or 9
So, now lets see a C-Program to print a even and odd numbers:
C-Program to print Even-Odd Number:
#include <stdio.h>
#include <conio.h>
void main()
{
int num = 0;
printf("Enter a number: ");
scanf("%d",$num);
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
}
Output:
Enter a number: 8 8 is even.

0 comments:
Post a Comment