Loops/For with a specified step: Difference between revisions
Content added Content deleted
(demonstrating decrementing with step, added output) |
(demonstrating incrementing by decimal values) |
||
Line 788: | Line 788: | ||
==={{header|True BASIC}}=== |
==={{header|True BASIC}}=== |
||
<lang |
<lang Qbasic> |
||
FOR i = 1 TO 21 STEP 2 |
FOR i = 1 TO 21 STEP 2 |
||
PRINT i; " "; |
PRINT i; " "; |
||
Line 794: | Line 794: | ||
END |
END |
||
</lang> |
</lang> |
||
{{out}} |
|||
<pre> |
|||
1 3 5 7 9 11 13 15 17 19 21 |
|||
</pre> |
|||
Since TrueBasic does not distinguish between integer or real values, we can increment using decimal values as well |
|||
<lang Qbasic> |
|||
FOR i = 1 TO 5 STEP .5 |
|||
PRINT i |
|||
NEXT i |
|||
END |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
1 |
|||
1.5 |
|||
2 |
|||
2.5 |
|||
3 |
|||
3.5 |
|||
4 |
|||
4.5 |
|||
5 |
|||
</pre> |
|||
==={{header|Visual Basic}}=== |
==={{header|Visual Basic}}=== |