Created
February 20, 2016 15:36
-
-
Save xanecs/b20f9f32dd2cd3028aba to your computer and use it in GitHub Desktop.
C Number guessing game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main () { | |
srand(time(NULL)); | |
int randNum = rand() % 9999; | |
while (1) { | |
printf("Guess a number: "); | |
int guessNum; | |
scanf("%d", &guessNum); | |
if (guessNum == randNum) { | |
printf("You are correct! Buy yourself a cookie!\n"); | |
break; | |
} | |
if (guessNum < randNum) { | |
printf("Your guess is too small!\n"); | |
} | |
else if (guessNum > randNum) { | |
printf("Your guess is too damn high!\n"); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment