Computers and Technology

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;
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:50, phillipfruge3
Match the personality traits with their description
Answers: 1
image
Computers and Technology, 22.06.2019 17:00, silvijaaa
The two main ways in which marketers address the competition with their strategies are by satisfying a need better than a competition and by
Answers: 2
image
Computers and Technology, 23.06.2019 01:00, lusciousl
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan. in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan. out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
image
Computers and Technology, 24.06.2019 05:30, lolololol21
Cómo pongo un tomo de llamada sin pagar?
Answers: 1
Do you know the correct 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:

Konu
Computers and Technology, 21.04.2020 19:06