Here you will get C program to check given number is even or odd.
We will use following simple logic in this program.
If a number is divisible by 2 then it is even.
If a number is not divisible by 2 then it is odd.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<stdio.h> int main() { int n; printf("Enter any number:"); scanf("%d",&n); if(n%2==0) printf("The number is even"); else printf("The number is odd"); return 0; } |
Output
Enter any number:17
The number is odd