Using the switch statement instead of if
so I just started programming and I started with c#. In the book I'm
reading (learning c# 3.0), one of the exercises was this.
Exercise 5-2. Create a program that prompts a user for input, accepts an
integer, then
evaluates whether that input is zero, odd or even, a multiple of 10, or
too large (more
than 100) by using multiple levels of if statements.
I managed to to this but the next exercise was
Exercise 5-3. Rewrite the program from Exercise 5-2 to do the same work
with a
switch statement.
I understand how switch statements work, but, I'm not sure how to work out
if the user input number is odd/even, multiple of 10 and so on, and not
use an if statement. Thank you for any help.
No comments:
Post a Comment