1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
navik [9.2K]
3 years ago
9

Write a function int guessing_game(num, rangemin, rangemax)that takes an integer and plays a guessing game with the user. Use th

e int ask_in_range(min, max)to get the user to guess a number num. If the guess is too low or too high, let the user know and ask for another guess. Keep asking for guesses until the user enters a correct guess that equals num. Keep track of number of guesses that the user took, and output that number when the game ends. Also make your guessing_game(num, rangemin, rangemax)function return that number.

Computers and Technology
1 answer:
n200080 [17]3 years ago
6 0

Answer:

Check the explanation

Explanation:

Code:

#include <stdio.h>

int ask_in_range(int min, int max)

{

int n;

printf("Please guess a number: ");

scanf("%d", &n);

 

while(n<min || n>max)

{

printf("Your number is outside of [-100, 100] range. Please enter a number: ");

scanf("%d", &n);

}

 

return n;

}

int guessing_game(int num, int rangemin, int rangemax)

{

printf("Hello and welcome to the game.\n");

printf("You need to guess a number between -100 and 100.\n");

 

int count = 1;

int guess = ask_in_range(rangemin, rangemax);

 

while(guess!=num)

{

if(guess<num)

printf("Too low!\n");

else

printf("Too high!\n");

 

guess = ask_in_range(rangemin, rangemax);

count++;

}

 

printf("Good job! You took %d guesses.\n", count);

return count;

}

int main()

{

int count = guessing_game(13, -100, 100);

return 0;

}

Kindly check the attached images below to see the CODE SCREENSHOT and CODE OUTPUT.

You might be interested in
What is syntax?
kkurt [141]

Answer:

A

Explanation:

5 0
3 years ago
Who has played pokemon red, blue, or yellow on the gameboy
lisov135 [29]

Answer:

I didn't think this would be an actual question... I did- :3

3 0
3 years ago
Read 2 more answers
One of the disadvantages of Photoshop Express is that it does not have a Black and White effect. True False
Katarina [22]
False,
The Pop Color tool can be used to select one particular color, changing the rest of the image to black and white. The effects available in Photoshop Express don't allow for a huge amount of customization
8 0
3 years ago
Where is the Outlook Search Folder located?
melamori03 [73]
When you go to the mail go to file and click new it should be in there as search folder
6 0
3 years ago
Write a program which will -
Hitman42 [59]

Answer:

down below

Explanation:

score = input() # gets student's score input

max = input() # gets max number

percent = (score/max)*100 # multiply by a hundred to get percentage

if percent > 52: # checks if percent is greater than 52

  print("well dont you have at least a grade 5")

else # if percent is less than or equal to 52 it will print this instead

  print("Unlucky, you need to revise more for the next test.")

THIS PART IS NOT CODE:

make sure you indent/tab the print statements or else you'll get an error

6 0
3 years ago
Other questions:
  • Which of these engine components forms a tight seal between the piston and the cylinder and is necessary for proper engine opera
    13·2 answers
  • Write a function called printEvens that prints all the even numbers between 2 and 20, inclusive. It will take no arguments and r
    6·1 answer
  • Ned and Mary Ann are saving their files to a CD. When prompted, Ned will click on Burn file to disk, indicate the recording spee
    15·1 answer
  • Review the portion of the application above. Record any changes or corrections that need to be made and why.
    13·1 answer
  • With which feature or menu option of a word processing program can you make an image like this?
    14·2 answers
  • What are the steps in preparing a bootable USB installer?​
    11·1 answer
  • In 3-5 sentences describe to me in detail how you can make a change and better our online community. What are steps would you ta
    8·2 answers
  • How many levels of heading tags are allowed in html?
    13·2 answers
  • Write a function, called valFrequency, that given a list of values as a parameter, counts the frequencies for each value in the
    14·1 answer
  • 1.Which of the serves as the basis for determining whether an object has moved or not?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!