Starting from:
$30

$24

CS Lab2 Solution

Write a program that simulates the “Guess a number” game. First, the program defines an integer between 1 and 100 as a constant. It then asks the user to enter a guess (between 1 and 100), and reads the user’s guess. According to the guess, the program prints an appropriate message “too low - try again” or “too high - try again”, and repeats doing the above until the user guesses the correct number. At the end, the program outputs how many guesses it took the user to find the correct number.

More products