C program: Write a single program with user-defined function(s) and random numbe
ID: 649098 • Letter: C
Question
C program:
Write a single program with user-defined function(s) and random numbers that asks the user to guess a number in the range of 10 to 100. The program helps the user find the number by telling the user it the guess is
Please enter today?s numerical day of the month: 17 A number has been generated in the range of 10 to 100. Can you guess the number? Please type your first guess: 50 Too low, try again Please enter your next guess: 80 Too high, try again Please enter your next guess: 70 Too high, try again Please enter your next guess: 60 Too low, try again Please enter your next guess: 65 Too high, try again Please enter your next guess: 64 Too high, try again Please enter your next guess: 63 Excellent! You guessed the number! Would you like to play again (yes = y or no = n)? y Please enter today?s numerical day of the month: 24 A number has been generated in the range of 10 to 100. Can you guess the number? Please type your first guess: 50 Too high, try again Please enter your next guess: 25 Too high, try again Please enter your next guess: 15 Too low, try again Please enter your next guess: 17 Too high, try again Please enter your next guess: 16 Excellent! You guessed the number! Note: Randomly randomized values will have various outputs and / or Quantity of guesses but Start with the date of 17 and use 50, 80, 70 no matter what and then adapt ... Play again and Start with date of 24 and use 50, 25, 15 no matter what and then adapt .... Would you like to play again (yes = y or no = n)? n Thanks for playing! Press any key to continue...Explanation / Answer
#include <stdio.h>
#include<conio.h>
#include<date.h>
#include <string.h>
#include <cstdlib.h>
void printIntro()
{
cout << "Program asks the user to guess a number in the range of 10 to 100." << endl;
cout << " The program helps the user to find the number by telling the user ";
cout << "it the guess is "too high" or "too low"" << endl;
}
int GetSecretNumber(int date)
{
srand(date);
int min = 10, max = 100;
cout << "A number has been generated in the range of " << min << " to " << max << endl;
return (rand() % (max - min + 1)) + min;
}
int GetUsersGuess()
{
int value;
cin >> value;
return value;
}
int main()
{
printIntro();
int secretNumber = 0, usersGuess = 0;
while (true)
{
int d;
cout << "Please enter today
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.