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!

Recommended Answers

All 2 Replies

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");
 printf("\nPlease enter the x-coordinates for your guess:");
 scanf("%d",x);

 printf("\nPlease enter the y-coordinates for your guess:");
 scanf("%d",y);

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

 printf("\nYour current guess is %d than your previous guess");

 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:
Please enter the x-coordinate for your guess: 21

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

Please enter the y-coordinate for your guess: 2

Your current guess is COLDER than your previous guess.

Guess #2:
Please enter the x-coordinate for your guess: 5
Please enter the y-coordinate for your guess: 5

You FOUND the hidden point. Congratulations.
------------------------------------------------------------------
Guess #10:
Please enter the x-coordinate for your guess: 7
Please enter the y-coordinate for your guess: 9

You have run out of guesses. The point was hidden at <3,17>.
Better luck next time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.