Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Show the odd numbers from to by skipping the even ones with continue.
continue skips the rest of the round and goes to the next one.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Go through . If a number is even (n % 2 == 0), continue skips the print.
Answer: the program shows .
Note. In a while loop, change n before continue. If continue came before n = n + 1, the loop would never stop.
Log in to join the discussion.
Loading…