BASIC Program to Find Even Numbers Using FOR TO NEXT statement

Sum = 0
FOR even = 2 T0 50 STEP 2
Sum = Sum + Even
NEXT even
PRINT "The even numbers are:"; Sum

Sum is initialised to 0. For variable name (even), Start from 2, step two numbers and stop at 50. This is how the even numbers will be selected. You can choose to print the even numbers to the screen instead of adding them together and assigning it to sum. The program would be

For even = 2 TO 50 STEP 2
Next even
Print "The even numbers are :"; Even

Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:

HTML Link Code:

BB (forum) link code: