Prerequisite:
Logic: Modulus of even number with 2 always be zero(n%2==0)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include<stdio.h> int main() { long int i_var; printf("\n Program to check entered number is even or odd"); printf("\nPlease enter any Number: "); scanf("%ld",&i_var); if((i_var%2)==0) { printf("\n%ld is an even number.",i_var); } else { printf("\n%ld is an odd number.",i_var); } return 0; } |
1 2 3 4 5 |
Output: Program to check entered number is even or odd Enter any Number: 344434343333556 344434343333556 is an even number. |