This is the code I have so far. I can't even get the numbers range to print to the screen correctly. I am very new to all this stuff so go eacy on me. Can anyone help??

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main()
unsigned int lo, hi;
int comp;
double tries = 0;
double guess = 0;

printf ("Please enter two integers for the range:\n");
scanf ("%d%d", &lo, &hi);

srand (time(0));
comp = lo + rand() % (hi - lo);

printf ("I'm thinking of a number between %d and %d!\n", lo, hi);
scanf ("%f", &guess );

while (guess != comp);
	if (guess < comp)
		printf ("Your guess was too low. Try again.\n");
		scanf ("%f", &guess);

	else if (guess > comp)
		printf ("Your guess was too high. Try again.\n");
		scanf ("%f", &guess);


printf ("Nice job! You got it in %f tries.\n", tries);

return 0;

Any help is very much appreciated.

guess and tries should be int's - you'll never have .23 of either! ;)

Try adding a lo, mid, and hi variable. Then, when the guess is too high, bring down the hi variable to your current guess-1.

When your guess is too low, bring up your lo to your current guess+1.

mid will always start each loop with: mid = (lo+hi)/2

This question has already been answered. Start a new discussion instead.