|
Post by brity on Oct 27, 2002 21:01:21 GMT
I am trying to write a program that will print out all the even numbers greater than zero and less than the ending number. The output should look like this; Even numbers between 0 and 5 (not including zero) 2 4 There were 2 even numbers from 0 to 5
|
|
Ziggi
Full Member
Posts: 87
|
Post by Ziggi on Oct 28, 2002 8:03:55 GMT
The only thing I thing of is a FOR NEXT loop.
FOR x = 0 to 5 step 2 ' step increment number every 2 IF x <> 0 PRINT x ' the IF checks that x is not 0 NEXT x
or to print numbers using MOD
FOR x = 0 to 10 ' chenge 10 to 5 for your need a = x MOD 2 ' if x = 2, 4 , 6 , 8 then a=0 IF a=0 AND x > 0 THEN PRINT x ' IF checks that a=0 and '........................................... x is grater then 0 NEXT x
|
|