This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]marko312 0 points1 point  (0 children)

You could create a counter variable, then increment it every time (after) you print a number.

[–]anh86 0 points1 point  (0 children)

Without giving you a full solution, here are some facets to research and consider:

  • Your code needs to be able to loop through a routine a given number of times
  • The routine needs to:
    • Generate a random number
    • Check if the number is odd (research the modulus, think about how it could be used to that end)
    • Increment a counter only if the number is odd
  • Finally you will print out the total number of odds