Even and Odd Numbers Using C Programming Language

Even Numbers : Any digit or number which can be divided by 2 or groups of 2 are called as even numbers. 
Numbers like 0 , 2 , 4 , 6 , 8 , 10 , 12 , 16 ...

Odd Numbers   : Numbers other than even numbers are called as odd numbers.
Numbers like 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 ...

Algorithm:
Need to check which numbers are divided by 2 for even odd numbers for a given range indicated by the user.

Read these articles:
Program Code:
#include<conio.h>
#include<stdio.h>

int main()
{
int num;
printf("Enter a number\n");
scanf("%d",&num);
printf("\n");

if(num%2==0)
printf(" %d is an Even number",num);

else
printf(" %d is an Odd number",num);

getch();

}

Output: After compile and run , the output will be


Hope that you will find this helpful.

2 comments:

  1. Nice coding. And as a friendly suggestion, you can add 'zero' as an "Undefined Exception" as this code clearly categorize it as "even" ;)

    ReplyDelete

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.