Showing posts with label FOR-NEXT. Show all posts
Showing posts with label FOR-NEXT. Show all posts

Tuesday, 14 February 2012

3 GW-BASIC [FOR-NEXT STATEMENT]

In GW-BASIC FOR-NEXT is use for looping , you can print any number more than 1 time easily .
how to write FOR-NEXT
10 FOR A=1 TO 10
20 PRINT SHAHZAIBBAIG
30 NEXT A
Where A is a variable , 1 TO 10 this will PRINT SHAHZAIBBAIG 10 times, you can PRINT more than ten time, its is useful and short STATEMENT of GW-BASIC , NEXT Command is must if u donot write at the end the loop will not work and give you syntax error.

Some Examples
10 FOR A = 3 TO 28 STEP 5
20 PRINT A
30 NEXT A
Where STEP 5 will PRINT Like this 3 then 8 then 13 then 18 ....

You Can also do this
10 FOR A= 28 TO 3 STEP -5
20 PRINT A
30 NEXT A
This will minus 5 from 28 , when 3 comes program will stop


Share

Widgets

 
Design by Shahzaib Baig