By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,054 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,054 IT Pros & Developers. It's quick & easy.

algorithm to find first n even numbers

P: 1
algorithm to find first n even numbers
Apr 20 '18 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
You use nested loops.

The outer loop runs for 7 cycles..

The inner loop begins with an int set to 2 and tests it to be even. If even, the loop displays the int and exits. if not even the loop inrements the int and repeats the test for even again.

By the time the outer loop exits, the inner loop wsill have displayed 7 values.
Apr 21 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.