Created
December 20, 2012 01:22
-
-
Save anonymous/4342265 to your computer and use it in GitHub Desktop.
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> | |
#include <string.h> | |
int main() { | |
int input=0; | |
int random_number = rand() / RAND_MAX; | |
random_number = random_number * 100; | |
int count=0; | |
while(1) { | |
printf("guess my number! You have 10 tries!"); | |
scanf("%d", input); | |
if(input > random_number) printf("smaller!"); | |
if(input < random_number) printf("bigger!"); | |
if(input == random_number) { | |
printf("you win!"); | |
break; | |
} | |
count++; | |
if(count>9) { | |
printf("you lose!"); | |
break; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment