Jump to content

Output Of Numbers


yrstruly
 Share

Recommended Posts

You don't need special code for that. You need to make a loop. You need to print. And you need to understand the modulo operator, sometimes called the remainder operator. It works the same in all languages, and telling odd numbers from even is its most common use. It looks like a percent sign: %

Link to comment
Share on other sites

For a setup where you need to test whether a number is odd or even, the modulo operator that Dad mentions is the way to go. For a simple setup like you've described, you could also use a for loop where the iterator is initialized at 2 and is incremented by two over each iteration.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...