Created
March 9, 2018 23:07
-
-
Save neodevelop/4add089b61ebc72c0ee95aa5ca6f9233 to your computer and use it in GitHub Desktop.
Guess my number in C
This file contains hidden or 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> | |
void guess(int n, int low, int upper){ | |
int guess_number = (upper + low) / 2; | |
if(guess_number < n){ | |
printf("Tu número no es %d\n", guess_number); | |
guess(n, guess_number, upper); | |
} | |
if(guess_number > n){ | |
printf("Tu número no es %d\n", guess_number); | |
guess(n, low, guess_number); | |
} | |
if(guess_number == n) | |
printf("Tu número es %d\n", guess_number); | |
} | |
int main(){ | |
int low_limit = 0; | |
int upper_limit = 1000; | |
printf("Hola mundo!!!!\n"); | |
guess(813, low_limit, upper_limit); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment