BASIC Program to Find Even Numbers Using FOR TO NEXT statement andrey воскресенье, 16 февраля 2014 г. No Comment

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


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
End.
CLS
Sum = 0
FOR even = 2 T0 50 STEP 2
Sum = Sum + Even
NEXT even
PRINT "The even numbers are:"; Sum
END


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
End.
by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment