Skip to content

Instantly share code, notes, and snippets.

@holachek
Created November 26, 2012 16:45
Show Gist options
  • Save holachek/4149246 to your computer and use it in GitHub Desktop.
Save holachek/4149246 to your computer and use it in GitHub Desktop.
Even or Odd program
// Tell me, is a number even or odd?
// Bug #1: Long integers cause scanf to truncate userNumber
#include <stdio.h>
int main()
{
int userNumber = 0;
printf("Enter an integer, please:");
scanf("%d", &userNumber);
if(userNumber%2 == 0){
printf("EVEN :)");
} else {
printf("ODD :(");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment