User Report

#include <iostream>

#include <string>

#include <cstdlib>

#include <ctime>

using namespace std;

int main()

{

srand(static_cast<unsigned int>(time(0)));

int randomNumber = rand() % 20 + 1;

int tries = 0;

int guess;

do

{

cout << "Take a shot at guessing a number between 1 and 20: \n";

cin >> guess;

++tries;

if (guess > randomNumber)

{

cout << "too high!\n";

}

else if (guess < randomNumber)

{

cout << " too low!\n";

}

else

{

cout << "You won! " << tries << " tries!\n";

}

if (tries>=5)

{

cout << "You have failed.\n";

break;

}

} while (guess != randomNumber);

system("pause");

return 0;

}

Submit Your Homework

Let us help you with your homework, we will match you with one of our professional tutors.

My Info

Project Info

Due Date

Describe your Homework Problem

Budget (optional)

By providing your budget we will work on finding the best tutors that can work within it.

Get help from top-rated tutors in any subject.

Efficiently complete your homework and academic assignments by getting help from the experts at homeworkarchive.com