#include #include #include using namespace std; int seed = time(NULL); int num, guess, attempts = 0; int min_val = 1, max_val = 20; // This assignment is worth 4 points int main() { srand(seed); num = rand() % (max_val - min_val + 1) + min_val; cout << "Guess my number (" << min_val << '-' << max_val << "): "; do { cin >> guess; cin.ignore(); attempts++; if(guess < num) cout << "Too low! Guess again: "; else if(guess > num) cout << "Too high! Guess again: "; else { if(attempts > 1) cout << "Correct! Achieved in " << attempts << " tries.\n"; else cout << "Correct! Achieved in " << attempts << " try.\n"; } } while(guess != num); return 0; }