Skip to content

Instantly share code, notes, and snippets.

@hakatashi
Created May 25, 2014 14:41
Show Gist options
  • Save hakatashi/6ce01fb35279d9c340fd to your computer and use it in GitHub Desktop.
Save hakatashi/6ce01fb35279d9c340fd to your computer and use it in GitHub Desktop.
What's happening here when I enter invalid numbers like 'a'?????
#include <stdio.h>
int main() {
int number;
while (1) {
printf("Enter your number: ");
scanf("%d", &number);
if (number > 10) {
printf("It's greater than 10! Excellent!\n");
break;
} else {
printf("You are poor. :( Please cool down and try it again.\n");
}
}
return 0;
}
Enter your number: a
You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
Enter your number: You are poor. :( Please cool down and try it again.
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment