More challenging challenges!
You now have three basic programming building blocks at your disposal.
So, here are more programming challenges for you!
- Add more features to the guessing game. Allow the user a maximum of 10 guesses, and output either
hot
,cold
orcorrect
at each guess, terminating either when the guess is correct or the user has exhausted all 10 attempts. - Check whether a year entered by the user is a leap year. Remember that just because a year is divisible by four does not necessarily mean that it is a leap year!
Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the years 1600 and 2000 are.
- List all prime numbers from 1 to N, where N is a number entered by the user. (Now, what is the definition of prime numbers again? 😊)
Try at least two of them before continuing on with the lesson!
Take your time, and I will wait for you in the next lesson.
And as usual, please remember to understand the problem first before trying to solve it!