Secret Number Guessing
Write a program with a secret integer between 1 and 100.
Use a do-while loop to allow the user to guess the number.
After each guess, the program should indicate whether the guess is too high, too low, or
correct. The loop should continue until the guess is correct.
Answer
#include <iostream>
int main() {
int secret = 84;
int guess;
do {
std::cout << "Guess the number between 1 and 100: ";
std::cin >> guess;
if (guess > secret)
std::cout << "Too high.\n";
else if (guess < secret)
std::cout << "Too low.\n";
else
std::cout << "Correct!\n";
} while (guess != secret);
return 0;
}