subject

In this warm up project, you are asked to write a c++ program proj1.cpp that lets the user or the computer play a guessing game. the computer randomly picks a number in between 1 and 100, and then for each guess the user or computer makes, the computer informs the user whether the guess was too high or too low. the program should start a new guessing game when the correct number is selected to end this run (see the sample run below).

check this example and see how to use functions time() and rand() to generate the random number by computer.

example of generating and using random numbers:

#include
#include // srand and rand functions
#include // time function
using namespace std;

int main()
{
const int c = 10;

int x;
srand(unsigned(time(; // set different seeds to make sure each run of this program will generate different random numbers
x = ( rand() % c);
cout < < x < < endl;
x = ( rand() % c ); // generate a random integer between 0 and c-1
cout < < x < < endl;
return 0;
}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, smariedegray
All of the following are characteristics that must be contained in any knowledge representation scheme except
Answers: 3
image
Computers and Technology, 23.06.2019 17:00, kyleemarie2003
Companies that implement and apply an information system effectively can create
Answers: 1
image
Computers and Technology, 23.06.2019 17:30, kenyasutton10
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
image
Computers and Technology, 23.06.2019 22:30, kayelynn003
How many points do i need before i can send a chat
Answers: 1
You know the right answer?
In this warm up project, you are asked to write a c++ program proj1.cpp that lets the user or the co...

Questions in other subjects: