Make a game in which you guess a number between two set numbers to find the answer, the game should tell you if you are too low in your guess or too high. For example
Guess a number between 0 and 10
user: 9
Too high!
Guess a number between 0 and 10
user:2
Too low!
Guess a number between 0 and 10
user: 5
You win!
The number must be randomly generated each game, the following function will yield a random number between 1 and 100000:
int randNum()
{
int i
time_t t1;
(void)time(&t1);
lrand48((long)t1); /*use time in seconds to set seed*/
return lrand48()/20000;
/*lrand48() returns non-negative long integers uniformly distributed over the interval (0~100000)*/
}
where libraries sys/types.h and time.h should be included.
requirments:
The game must include at least three difficulties(bonus: add a custom difficulty so the user can define the high number), should tell you how many guesses it took to get it, must use a loop, and a switch statement. The game must also look nice.