Home >>c programs >c program to check odd or even
Even numbers are those numbers which are perfectly divisible by 2 else it is an odd number.
There are two ways to check whether the input number is even or odd:
Let's take an example :
#include <stdio.h> int main() { int num=11; if(num%2==0) { printf("Given Number is eveno num %d",num); } else { printf("Given Number is odd num %d",num); } }
A user inputs a number, and we check whether it’s a even or odd. when the input number is completely divisible by 2 then it's an even number otherwise its an odd number.
Let's take an example :
#include <stdio.h> int main() { int num=0; printf("enter Your number:"); //get input and store in num variable scanf("%d",&num); if(num%2==0) { printf("Given Number is even num"); } else { printf("Given Number is odd num"); } return 0; }