This is what I have for a user-defined range and everything works properly until I upload it to the upload site. The first run works but the second run gives an infinite output of "Too Low". What am I doing wrong?
Code:#include <stdio.h>
#include <stdlib.h>
#define min(a,b) ((a)>(b)?(b):(a))
int main ()
{
unsigned int a,b,count=0,range;
unsigned int guess=0,answer;
printf("Enter 2 integers for the range\n");
scanf("%d %d", &a, &b);
printf("I'm thinking of a number between %d and %d\n", a, b);
range=b-a;
srand(min(a,b));
answer=(rand()%(range+1)+a);
while(guess!=answer)
{
printf("Pick a number\n");
scanf("%d",&guess);
if(guess==answer)
{
printf("You guessed correctly\n");
}
else if(answer< guess)
{
printf("Your guess is too high\n");
}
else
{
printf("Your guess is too low\n");
}
count++;
}
printf("It took you %d time(s)\n", count);
return 0;
}