Chapter 3.2 - Exercise
Sum up numbers
Write a program, which asks the user to input numbers, until the user enters 0. The program should then add those numbers up and print the total sum at the end.
Note: It is OK for now for the program to crash if the user enters anything which is not a number. We will deal with that in a later chapter.
Print even numbers
Write a program, which prints all even numbers between 3 and 42 to the terminal.
Count even and odd numbers
Similar to the first exercise, the user should input numbers until the inputted number equals 0. Instead of the sum, the program should print how many even and how many odd numbers the user inputted.
Hint: To figure out whether a number is even or odd, you might want to use the modulo operator, which we discussed in chapter 2.1.