23 lines
706 B
C++
23 lines
706 B
C++
#include <iostream>
|
|
#include "guess_a_number.h"
|
|
|
|
int main() {
|
|
// Declare the required variables
|
|
int number_to_guess; // The number to guess
|
|
int guess; // The guessed number
|
|
|
|
// Pick the number to guess
|
|
std::cout << "Number to guess: ";
|
|
number_to_guess = choose_a_number(3); // Randomly choose a number from the interval [1, 3]
|
|
|
|
// Save number inputted by user into variable guess
|
|
std::cin >> guess;
|
|
std::cout << "Your guess: ";
|
|
|
|
if (guess == number_to_guess) {
|
|
std::cout << "Congratulations, you correctly guessed " << number_to_guess << "!";
|
|
} else {
|
|
std::cout << "Sorry, but " << guess << " is wrong, " << number_to_guess << " was the number to guess.";
|
|
}
|
|
}
|