algorithm to find first n even numbers
algorithm to find first n even numbers
Collapse
X
-
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