Monday, 7 March 2016

C Program For Check Number Is Even Or Odd

Problem :- Write A C Program For Check Number Is Even Or Odd

Logic :- Logic is very very simple as we know that if number is divisible by 2 then number is Even else Number is Odd 
Example :- number form 1 to 10 .
1-Odd
2-Even
3-Odd
4-Even
5-Odd
6-Even
7-Odd
8-Even
9-Odd
10-Even

Try Yourself C++ Program To Check Year Is Leap Year Or Not

Solution :- 

#include<stdio.h>

int main()
{
int num;

printf("\nEnter Any Number To Check Even Or Odd :\n");
scanf("%d", &num);

if (num%2 == 0)
{
   printf("%d is EVEN\n", num);
}
else
{
   printf("%d is ODD\n", num);
}
return 0;
}

Output:-

C Program For Check Number Is Even Or Odd

No comments:
Write comments

Recommended Posts × +