algorithm to find first n even numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • k ancion
    New Member
    • Apr 2018
    • 1

    algorithm to find first n even numbers

    algorithm to find first n even numbers
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    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.

    Comment

    Working...