I need help writing a program that randomly picks a point in a 2D space. Then the user will be allowed to make repeated guesses which point was picked with feedback saying if the user is hot or colder on each guess. Thank you!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by yasaswyg

I need help writing a program that randomly picks a point in a 2D space. Then the user will be allowed to make repeated guesses which point was picked with feedback saying if the user is hot or colder on each guess. Thank you!

Could we see what you have so far?

Could we see what you have so far?

``````#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "checkit.h"

int hot_or_colder(int x, int y, int hx, int hy, pd)
{

}

int get_valid_coordinate(int

int main ()
{
srandom(time(0));
x=(int)(random()%20);
y=(int)(random()%20);

printf("\nWelcome to the Hotter-Colder game.");
printf("\nGuess the coordinates of the hidden point. Each coordinate
will be between 0 & 19");

printf("\nGuess #%d");
scanf("%d",x);

scanf("%d",y);

printf("\nYou entered a number outside of the valid range of 0 to 19");

printf("\nYou FOUND the hidden point. Congratulations!");

printf("\nYou have run out of guesses. Th point was at <"%d,%d">,);

return 0;
}``````

This is what I have till right now. I need help making the random number function and comparing it to the current guess.
The output is to suppose to look some what like this:

Guess #1:

You entered a number outside of the valid range of 0 to 19.
Enter another number: 2

Guess #2: