Write a program to have the computer guess at a number between 1 and 20. This program has you, the user choose a number between 1 and 20. Then I, the computer will try to my best to guess the number. Is it a 18? (y/n) n Higher or Lower (h/l) l Is it a 5?(y/n) n Higher or Lower (h/l) h Is it a 10? (y/n) y I got tour number of 10 in 3 guesses.

Answers

Answer 1

Answer:

This question is answered using C++ programming language.

#include<iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main(){

   int num, computerguess;

   char response, hl;

   cout<<"Choose your number: ";

   cin>>num;

   srand((unsigned) time(0));

   int high = 20;    int low = 1;    int guess = 0;

   computerguess = low + rand() % high;

   cout<<"Is it "<<computerguess<<" ?y/n: ";

   cin>>response;

   while(response == 'n'){

       cout<<"Higher or Lower? h/l: ";

       cin>>hl;

       if(hl == 'h'){            low = computerguess+1; }

       else{   high = computerguess-1; }

       guess++;

       computerguess = low + rand() % high;

       cout<<"Is it "<<computerguess<<" ?y/n: ";

   cin>>response;

   }

   cout<<"I got your number of "<<num<<" in "<<guess+1<<" guesses.";

   return 0;

}

Explanation:

This declares num (user input) and computerguess as integer

   int num, computerguess;

This declares response (which could be yes (y) or no (n) and hl (which represents high or low) as char

   char response, hl;

This prompts user for input

   cout<<"Choose your number: ";

This gets user input

   cin>>num;

This allows the computer be able to generate different random numbers at different intervals

   srand((unsigned) time(0));

This declares and initializes the range (high and low) to 20 and 1 respectively. Also, the initial number of guess is declared and initialized to 0

   int high = 20;    int low = 1;    int guess = 0;

Here, the computer take a guess

   computerguess = low + rand() % high;

This asks if the computer guess is right

   cout<<"Is it "<<computerguess<<" ?y/n: ";

This gets user response (y or n)

   cin>>response;

The following iteration is repeated until the computer guess is right

   while(response == 'n'){

This asks if computer guess is high or low

       cout<<"Higher or Lower? h/l: ";

This gets user response (h or l)

       cin>>hl;

If the response is higher, this line gets the lower interval of the range

       if(hl == 'h'){            low = computerguess+1; }

If the response is lower, this line gets the upper interval of the range

       else{   high = computerguess-1; }

This increments the number of guess by 1

       guess++;

Here, the computer take a guess

   computerguess = low + rand() % high;

This asks if the computer guess is right

   cout<<"Is it "<<computerguess<<" ?y/n: ";

This gets user response (y or n)

   cin>>response;    }

This prints the statistics of the guess

   cout<<"I got your number of "<<num<<" in "<<guess+1<<" guesses.";


Related Questions

Which examples demonstrate common education and qualifications for Manufacturing Production Process Development careers? Check all that apply. Answer: A. Hugo uses CAD software to create a product design. D. Latisha is a Mechanical Engineer with a bachelor's degree. E. Oliver carefully calculates the dimensions of a product.

Answers

Answer:

A D E

Explanation:

I got it right on Edge.

Answer:

A D E

Explanation:

just did the work

:)))))

2. Media sharing websites let you post photos and videos to share with other people. What are the benefits and drawbacks of using these websites?

Answers

Media sharing websites let you post photos and videos to share with other people. The benefit is that we are up to date and get all the news as well as information worldwide.

What is company's website?

The website of the company is all web sites which is operated by any occupied company or via any occupied company conducts the business. Any business website is a website that is designed in such a way that it can represent the identity of a business on the internet.

Company's name and fame id totally depends upon advertisement and its products and websites play an important role in order to make company popular and due to this reason company used the website or designed the website in unique and knowledgeable manner.

Therefore, Media sharing websites let you post photos and videos to share with other people. The benefit is that we are up to date and get all the news as well as information worldwide.

Learn more about website here:

https://brainly.com/question/19459381

#SPJ2

The ______ occurs in first-come-first-served scheduling when a process with a long CPU burst occupies the CPU. Group of answer choices

Answers

Answer:

convoy effect

Explanation:

The Convoy effect is an episode in Operating System, in which if the burst time of the first process is high among all the processes, then it effects the First-Come-First-Serve algorithm.

Just like in real incidents, when a convoy is heading first in the slows down the vehicles behind; same happens in the Operating System. If long CPU burst occupies first in the ready queue, then it slows, or even in some cases, block other low processes. This effect is also known as starvation.

Therefore, the correct answer is convoy effect.

Which of the following identifies the most appropriate courses to take in high school for someone interested in becoming a mechanical engineer?
drafting- and math-related courses
math- and science-related courses
computer- and design-related courses
science- and computer-related courses

Answers

Answer: New questions in Health

Which member of the multidisciplinary team would help a patient improve his flexibility in the joints after a knee-replacement surgery? A. a physiot…

What are two advantages of a multidisciplinary team approach? better diagnosis in complex cases shared responsibility for decisions more opportunit…

MARKING PEOPLE AS BRAINLIST PLEASEEE HELP Where is the carbon dioxide picked up and the oxygen unloaded in the body? A:Arteries B:Veins C:Capillar…

Which healthcare professional would be primarily responsible for treating a patient for his anxiety disorder after a surgery? A. a nurse B. a nutr…

Do Now: What might be a situation where it might be important to identify 3 points somebody? What are different strategies that scientists could use …

Explanation:

put each sentence in the correct place please :)

Answers

the first image matches with the last sentence.

the second image (fireworks) match with the first sentence.

the third image (rocket) matches with sentence two.

and the last image matches the third sentence.

Answer:

sentence 1 -> picture in box 2

sentence 2 -> picture in box 3

sentence 3 -> picture in box 4

sentence 4 -> picture in box 1

PLEASE ASAP!!

Today, most film editors manually cut and splice the actual film footage once it arrives.


O True
O False

Answers

The correct answer should be true, as their job is to *edit* the footage.

Answer:

True

Explanation:

edg2021

The film editor is such an important person on a film that he is often hired before the cast and other crew. This editor is responsible for revising the filmed footage until it becomes the finished film. The editor begins by reading the script to get familiar with the story. It is important for the editor to know the script because film scenes are generally shot and edited out of sequence. When footage begins to come in, the editor reviews the footage and production notes provided by the director and production team. These notes contain details about the footage and the director’s comments about the footage. The editor then uploads or transfers the footage to computers in the editing bay and begins editing the footage into finished scenes. The editing bay is the control room with editing equipment, computers, monitors, and sound system where film editors manipulate plot, sound, graphics, and score to produce a well-constructed scene. This is a painstakingly detailed and time-consuming task

⚠️ HURRY TIME IS TICKING ⚠️
Sierra needs to ensure that when users are entering data into a datasheet or form that they are limited in the values that they select. Which option should she use as the data type?
• Lookup list
• Bound value
• Short-text
• Date/time

Answers

Answer:

To ensue that data entering data is limited, Usually A dropdown list is used but here in the available option

Lookup list is correct.

Explanation:

Let explain why we have selected Lookup list

A lookup list is used to look for some value in a list.

For example in Excel we select a column for search which is basically limiting the value which we search.

Bound Value

we usually have 2 bounds ,

lower and upper bound

lower bound is the smallest value in a set while upper bound it the highest value in a set.

Short Text:

Short text is used to minimize the word.

For example instead of United States we simply write US

Date/Time are used for data/time value.

so the most appropriate answer is Lookup list.

What are the advantages and disadvantages of top-down and bottom-up programming? How would you decide which one to use? Do you approach problems in your real life from a bottom-up or top-down approach?

Answers

Answer:

Question: What are the advantages and disadvantages of top-down and bottom-up programming?

Answer:

Top-down programming is a process of writing programming codes that contain specific instructions for a computer to carry out the instructed task. Usually, Top-down programming comes as software that enables the division of problems that are initially complex into simpler parts. An example is a kind of software developed to give loans to worthy clients. The software may be broken down further to check the bank statements of the client, calculate the earning and spending capacity of the client, Amount paid on utilities.

Advantages of Top-down programming:

1. Top-down programming makes teamwork possible as a system is divided into sub-systems which individuals can handle separately before merging the sub-systems together.

2. Checks and testing become easy.

Disadvantages of Top-down programming:

1. Breaking systems into parts may be time-consuming as there is a need for more planning before working on individual sub-systems.

2. Error could be possible.

Bottom-up programming is a software of a method of design which is opposite to what the top-down programming does as the bottom-up programming works on the sub-systems first and then combine later into a bigger system. This makes use of the existing resources with the aim of generating a bigger result.

Advantages of Bottom-up programming:

1. Adaptability - Bottom-up programming makes adaptability easier.

2. When used in a company it gives all workers the room to make a contribution towards achieving bigger results, improving operations generally.

3. It makes one start a bigger project with the available resources.

Disadvantages of Bottom-up programming:

1. Result could be affected as some workers lack the needed experience to execute some tasks successfully.

2. Lack of desired unity among workers with differences in objectives resulting to endangering the result.

Question: How would you decide which one to use?

Answer:

It depends on the picture of how the result would look like, the goal of the organization employing it, the skill-set among workers available to do the task, the nature of the task. If a larger goal is to be achieved, smaller sub-systems could be used and joined at the end to get a system meaning bottom-up programming would be used. In cases for instance where output is to be determined for instance staff salaries, the output would be broken into simpler units to allow solutions for separate units then we could use top-down programming.

Question: Do you approach problems in your real life from a bottom-up or top-down approach?

Answer:

I approach problems from a top-down approach because it allows checks and testing easy, and the act of breaking systems into sub-systems makes it easy for me to approach each sub-system with a result-oriented plan.

Answer:

Some advantages of top-down are that you can start off from what you know and figure out what you need to complete it, the advantage to bottom-up is that you can make something new . if you are starting something from scratch and you don't know what the end goal might be you would use bottom-up but if you already have an idea or the final product of what you want you would go with the top-down approach.

Hope this helpedHave a great day!

ILL GIVE BRAINLIEST HELLP.
in windows 8, the _____ manager is the app that allows you to manage your hardware drivers on your computer .
a. device
b. drivers
c.system
d.utilities

Answers

Answer:

Device Manager

Explanation:

The Device Manager is used to check for hardware that have been installed on your system such as RAM, CPU, GPU etc. However, it has the option to update drivers for any hardware that you such desire.

please help, thank you

Answers

Answer:

radish spinach swiss chard

Explanation:

radish, swiss Chard, spinach

HELP ME!!! I WILL GIVE BRAINLY THINGY!!!

What does the code if (num2==50){ do?

Answers

Answer:

What subject is this?

Explanation:

is this math ?????????????????????

answer this now
and thanks

Answers

Answer:

the process of burning something

Answer:

Option D) the process of burning something

Explanation:

Combustion, or burning, is a high-temperature exothermic redox chemical reaction between a fuel and an oxidant, usually atmospheric oxygen, that produces oxidized, often gaseous products, in a mixture termed as smoke. 

5. What is a domain name used for?​

Answers

Answer:

Domain names serve to identify Internet resources, such as computers, networks, and services, with a text-based label that is easier to memorize than the numerical addresses used in the Internet protocols. A domain name may represent entire collections of such resources or individual instances.

Explanation:

*Hope this helps*

what does good time management mean​

Answers

Answer:

When you are consistent with your work and not wasting time

Explanation:

Time management to me means using your time wisely and thing you have to get done do those things first before doing something that is not a must. Being wise with your time will help you complete goals and more in life.

Have a good day and a merry Christmas

list and explain three computing devices from the 20th century​

Answers

Answer:

Calculating Machine

Graphic tablet.

Touchscreen

Explanation:

Hope this helps.

Brain-List?

Answer:

1. The First Calculating Machine (Pascaline)

2. Jacquard's Loom

3. The First Pocket Calculator

Explanation:

1. Pascaline was the first calculator or adding machine to be produced in any quantity and actually used. It was deigned at about 1642-1644.

2. Jacquard Loom is an attachment for powered fabric looms

3. The first truly pocket-sized electronic calculator was the Busicom LE-120A "HANDY" It was marketed in 1971.

How do you do that ( the bit that I circled in the picture)

Answers

Answer: You just type answer, return/enter, put your answer and then hit return/enter again

Explanation:

identify the information that's safe to send via e-mail

Answers

Answer:

nonehdbdjsjnajsjfjsap

Explanation:

baba booey

Why are backlinks a useful way to see if information on a website is reliable

Answers

Answer: It would help because the backlink could have the necessary details about the information being told. Hope it helps!

A common error by beginning programmers is to forget that array subscripts start with ________.
a. 0
b. the number of elements in the array
c. spaces
d. 1

Answers

Answer:.

Explanation:

The French horn was originally used as a hunting horn.

A. True
B. False

Subject: Music Technology.

Answers

Answer:

A. True

Explanation:

The French horn is a brass instrument delivered from the hunting horn. The first development of the instrument was in service of the hunt or signal of danger. Additionally, they were used in Jewish religious rituals. It was less complex than the instrument used today. Around the beginning of the 18th century, it started to be widely used as a musical instrument.

Today, it is played by the musicians called hornists, and there are usually four horns in the symphony orchestra. There are few variations of the instrument – single horn, double horn, compensating double horn, and triple horn.

help now ASAP, and thank you

Answers

Answer: True

Oxygen is needed to combust/ignite the fuel that is mixed in, which provides the heat and thrust to push the jet forward. On a chemical level, the oxygen (O2) mixes with whatever the fuel chemical may be. Recall that oxygen is often used to burn things, due to oxygen effectively breaking the bonds of the fuel chemical and unleashing its stored potential chemical energy.

What security concept states a user should only be given the minimum set of permissions required to perform necessary tasks

Answers

The correct answer is least functionality. I hope this helps.

The Internet:

O A. only gives us access to our local communities.

O B. hinders our ability to influence people.

O C. limits us to local social networking sites.

O D. enables us to join global online communities.​

Answers

Answer:

D- it enables us to join global online communities.

Explanation:

Thanks to social media and other websites, content you produce can be seen all over the world.

If you would like to compare information on two different Web pages, you should _____.
scroll through the pages
the home page
use tabs
organize bookmarks

Answers

Answer:

Use Tabs

Explanation:

I had this lesson on odyessy ware and this was right the other guy is wrong

Answer:

Use Tabs is also correct on Edge nuity

Explanation:

i have Keyboarding and Apps

how do I take a picture of myself on an apple computers?

Answers

Answer:

with the camera

Explanation:

Answer:

press the camera and take a pic??

Explanation:

help plz, u just gotta select all that apply :)

Answers

Answer:

Concept: Graph Analysis

We want to know all those that produce around 0.01 kg: Parsly, Coriander, Mint, Strawberry Rate positively and give brainlist

You are running an 802.11g wireless router in mixed mode. You have three 802.11g wireless NICs connected to the router. A new user connects to an 802.11b wireless NIC. What will happen

Answers

Complete Question:

You are running an 802.11g wireless router in mixed mode. You have three 802.11g wireless NICs using the router. A new user connects using an 802.11b wireless NIC. What will happen?

Group of answer choices.

A. The user with 802.11b will access the network at 11Mbps while the users with 802.11g will access the network at 54 Mbps.

B. The user with 802.11b will not be able to communicate on the network.

C. The user with 802.11b will access the network at 11 Mbps. The users with 802.11g will access the network at 54 Mbps unless they are communicating with the 802.11b device,which will be at 11 Mbps.

D. All users will access the network at 11 Mbps.

Answer:

D. All users will access the network at 11 Mbps.

Explanation:

A 802.11g is one of the wireless network standards developed by the Institute of Electrical and Electronics Engineers (IEEE) which operates on a 2.4 GHz microwave bandwidth and as a result can only transmit over a short distance. The 802.11g has a data transfer rate or throughput of 54 megabits per seconds (Mbps).

Basically, the 802.11b is a similar standard to the 802.11g wireless standard that typically allows the transmission (transfer) of data for up to 11 megabits per seconds (Mbps).

In this scenario, you are running an 802.11g wireless router in mixed mode. You have three 802.11g wireless NICs using the router. A new user connects using an 802.11b wireless NIC.

Hence, what will happen is that, all the users will access the network at 11 Mbps.

What is globalization? O A. A constant change in weather patterns that is occurring all over the globe OB. A movement for countries to turn to an economy based on bartering C. The movement from many local economies to one economy that is global O D. The tendency for global companies to create small local businesses ​

Answers

Answer:

The movement from many local economies to one economy that is global

Explanation:

Globalization is when companies and governments from around the world come together through interaction.

James wants to create a web page where he can write two paragraphs of text. The first paragraph of text should be colored red and the
second blue. Which snippet of code show the principle behind how James creates this page?

Answers

Answer:

The first code does it

Explanation:

Each of the attached code snippet is divide into two parts.

The CSS partThe html part

From the four code snippets, the first one answers it.

The syntax to format the paragraph of an html text using css is:

p#paragraph-id{

color:color-name

}

Analysing each element

p# -> This implies that a paragraph is to be formatted

paragraph-id -> This represents the id of the paragraph

{} -> The open and close curly braces house the properties to be formatted

color:color-name -> implies that the color of the element be changed to color-name (e.g. red or blue)

In the body tag of the html code, the first paragraph has an id of para1 and the second has para2 as its id.

i.e. <p id = "para1">......

So, the first paragraph will be formatted red while the second will be blue


Nick is moving from Alabama to Texas. A friend of his remarked that Nick may have to pay higher taxes there. What is the cheapest and quickest
way for Nick to find out if his friend is right?
А.
hire a lawyer
B.
speak to an accountant
C.
talk to other friends
D
look up the Texas state website

Answers

Answer:

d is look up the Texas state website

Explanation:

because tell u about texas and taxes

Other Questions
Enter the common ratio for this geometric sequence:8,4,2,....Give your answer in its simplest form. Find the value of x. Everything is in the photo. standard form of 80000 Rose plz. give me chance to explain You are planning to save for retirement over the next 25 years. To do this, you will invest $820 per month in a stock account and $420 per month in a bond account. The return of the stock account is expected to be 10.2 percent, and the bond account will pay 6.2 percent. When you retire, you will combine your money into an account with a return of 7.2 percent. How much can you withdraw each month from your account assuming a 20-year withdrawal period Scientists have observed many types of tropical fish moving beyond their traditional ocean ranges into waters that have historically been more temperate. These fish compete for food with native fish, consuming much from the kelp forests and beds of sea grass. The expansion of the ranges of tropical fish was most likely caused by *A-global droughts that raise the salt concentration of ocean watersB-the rising temperatures of ocean watersC-agricultural runoff that contributes to dead zones in the oceanD-acid rain pollution that lowers the pH of ocean waters A large multiplex movie house has many theaters. The largest theater has 50 rows. There are 12 seats in the first row. Each row has two seats more than the previous row. How many total seats are there in this theater? Which equation could generate the curve in a graph below? Sorry to bother but i need someone to talk to me if your older than 15 don't bother to message thank,you Can you please show your work and explain if possible. Give an example of a place where the colors of the room would need to be chosen carefully to create the right mood. Explain the color(s) that should be chosen and why it is the right look for that place. What was the geography like in the Southern Colonies? For your 13th answer in #4, what is the other name for this particle? Help pls!Read the excerpt from chapter 6 of Animal Farm.Afterwards Squealer made a round of the farm and set the animals minds at rest. He assured them that the resolution against engaging in trade and using money had never been passed, or even suggested. It was pure imagination, probably traceable in the beginning to lies circulated by Snowball. A few animals still felt faintly doubtful, but Squealer asked them shrewdly, "Are you certain that this is not something that you have dreamed, comrades? Have you any record of such a resolution? Is it written down anywhere?Which statement best explains how the pacing in this passage helps reveal Squealers character?A) The quickening pace builds suspense about Squealers next course of action.B) The quickening pace shows how Squealer is similar to Snowball.C) The foreshadowing shows that Snowball and Squealer are actually very different. D) The slowing pace shows how Squealer controls the animals with propaganda. define or understand freedom as a human person 6 yd8 ydWhat is the length of the hypotenuse?C =yards whats he length of side a? will give brianliest!!! Helppppp will mark brainliest Who was John Dawson?a. He was a successful farmer and rancher with a sense of adventure.b. He was a struggling fammer with severe debt left by the Dust Bowl.c. He was a railroad man with no interest in business. d. He was a politician who made his fortune in land grants. Make the correct match. 1. Type of instruments in Cubist paintings Guernica 2. They used color to ravish the eye Czanne 3. The preeminent center of modernism Paris 4. The ultimate modern artist modern 5. Les Demoiselles DAvignon is known as the first of this kind of painting musical 6. Painting depicting Nazi bombing Cubists 7. Person who coined the term cubism. art critic 8. Artist who influenced Picasso Picasso 9. Artists who typically worked in monochrome Fauvists