Mega Code Archive
Categories
/
C
/
Code Snippets
Use the mod % operator
#include
int main(void) { int j; printf("Enter a number: "); scanf("%d", &j); if( ( j % 2 ) == 0) printf("Even"); if( ( j % 2 ) ==1) printf("Odd"); return 0; }