Aprendendo Programação de Computador (Engenharia de Software) - Aula 33 Comandos de repetição. Questão 12
5.0(1)
8 learners
What you'll learn
This course includes
275.5 hours of video
Certificate of completion
Access on mobile and TV
Summary
Full Transcript
12. Create a guessing game following the specification below:
- Generate a random integer number from 1 to 100 (inclusive)
- Let the user try to guess the number until it get the right number
- For every guess the program should update the new interval
- At the end, print how many tries the player used
- e.g. Generated number = 35 (The player can't see this number)
- If only one number left in the interval the player lose the game
Try to guess a number from:
1 to 100 = 20
21 to 100 = 65
21 to 64 = 30
31 to 64 = 41
31 to 40 = 36
31 to 35 = 35
Congratulations you guessed the right number with 6 attempts!
Continue this lesson in the app
Install CourseHive on Android or iOS to keep learning while you move.