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
You need to configure your Android phone so that you can receive your Yahoo email on the device. What information would you need
Llana [10]

Answer:

To configure an Android phone to receive Yahoo email on the device, you would need to provide the:

full Yahoo email address and password.

Explanation:

The provision of your full Yahoo email address and password enables you to receive your Yahoo emails on the device.  Most often, the device requests to save the information to enable it to notify you of incoming emails.  There are settings for the provision of this notice.  The user can also synchronize Yahoo emails on all the devices by selecting the Sync button.

5 0
2 years ago
I need help 40 points and brainless if you answer
Reil [10]
The answer is c
But I’m not sure
8 0
3 years ago
Read 2 more answers
Which of the following can be used to determine how much traffic a website is getting?
Bumek [7]
Analytics can be used to determine the amount traffic a website is getting. The correct option among all the options that are given in the question is the second option. Web analytics is used to determine several important information’s about a website. This feature can also be used to determine the region from which the maximum and the minimum traffic is arriving. Based on the information’s received from analytics, the website owner can take steps to improve the amount of traffic that is coming to the website.



6 0
3 years ago
Write a function which sorts the queue in order from the smallest value to the largest value. This should be a modified version
PilotLPTM [1.2K]

Answer:

#include <iostream>

using namespace std;

void swap(int *a,int *b){    //function to interchange values of 2 variables

   int temp=*a;

   *a=*b;

   *b=temp;

}

void sort(int queue[],int n)

{

   int i,j;

   for(i=0;i<n;i++)      //to implement bubble sort

   {

       for(j=0;j<n-i-1;j++)

       {

           if(queue[j]>queue[j+1])

               swap(queue[j],queue[j+1]);    //to swap values of these 2 variables

       }

   }

}

int main()

{

   int queue[]={6,4,2,9,5,1};

   int n=sizeof(queue)/4;  //to find length of array

   sort(queue,n);

   for(int i=0;i<n;i++)

       cout<<queue[i]<<" ";

   return 0;

}

OUTPUT :

1 2 4 5 6 9

Explanation:

In the above code, Queue is implemented using an array and then passed to a function sort, so that the queue can be sorted in ascending order. In the sort function, in each pass 2 adjacent values are compared and if lower index value is greater than the higher one they are swapped using a swap function that is created to interchange the values of 2 variables.

7 0
3 years ago
George wants to edit the font of the title in his presentation. Where can he find the option to edit it?
Bad White [126]

The answer could be B. Tool Bar

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following functions and expressions will convert the ASCII character "Z" to its numeric equivalent ASCII code?
    7·1 answer
  • Double any element's value that is less than controlValue. Ex: If controlValue = 10, then dataPoints = {2, 12, 9, 20} becomes {4
    8·2 answers
  • How many words fit on a double-spaced page?
    11·1 answer
  • Signing up for a(n) ____ will automatically provide you with web content that is updated on a regular basis.
    15·1 answer
  • Please help ASAP, will mark brainliest!
    13·1 answer
  • One of the newest electronic conveniences is the ________, which can serve as a credit card, a debit card, and even unlock doors
    12·1 answer
  • Complete the statement using the correct term.
    10·1 answer
  • All the network nodes are connected to each other
    8·1 answer
  • How does Shakespeare immediately introduce Tybalt as a menacing character?
    9·1 answer
  • What defines the scope of a project?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!