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
Please help me!!
Alona [7]
Page layout and header i think is correct 
5 0
3 years ago
A computer that delivers requested web pages to your computer or mobile device is a(n) _____.
yaroslaw [1]

Answer:

Web Server

A web server is server software, or hardware dedicated to running this software, that can satisfy client requests on the World Wide Web. A web server can, in general, contain one or more websites. A web server processes incoming network requests over HTTP and several other related protocols.

6 0
4 years ago
Explain word processing ​
riadik2000 [5.3K]

Answer:

Word processing refers generally to the creation, editing, formatting, storage, and output of both printed and online or electronic documents. Word processing is undoubtedly the most-used business application for personal computers, perhaps alongside World Wide Web browsers and electronic-mail (e-mail) applications.

Explanation:

6 0
4 years ago
Read 2 more answers
PLEASE HELP I HAVE BEEN STUCK ON THIS QUESTION FOR 5m NOW
Nataly_w [17]

Answer:

They are personal, formal and informal.

Explanation:

Hope this helps!

3 0
3 years ago
Read 2 more answers
Cual es la <br> importancia de la netiqueta cuando nos comunicamos con el internet
jeka57 [31]

Answer: ight

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • A _________ provides multiple ports for connecting nodes and is aware of the exact address or identity of all the nodes attached
    15·2 answers
  • Which is the last step in conducting a url research
    11·1 answer
  • How can investors receive compounding returns
    13·1 answer
  • What is the full path of the directory on this computer containing the SAM registry hive file
    15·1 answer
  • We are committed to creating and cultivating a graduate and postdoctoral community that values and respects individuals, regardl
    11·1 answer
  • True / False<br> Generally, more orthogonal instruction sets are considered less elegant.
    10·1 answer
  • Trish has bought a new computer that she plans to start on after a week
    5·1 answer
  • Verbs in the active and passive voice
    14·1 answer
  • ________ is the use of information technology to support the sharing of content among networks of users.
    14·1 answer
  • Write a function named count_vowels that accepts two arguments: a string and an empty dictionary. The function should count the
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!