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


3 comments:

Unknown said...

it shows the error says: next without for

Shakeel Ahmed said...

it wont,
it's most simplest program...
#mariayasir

Ali said...

https://www.youtube.com/watch?v=WSBu2t81Aec&list=PLO3e4ITl12R7_E_jTCc7Yax4jTtcBvdAj

Post a Comment

Share

Widgets

 
Design by Shahzaib Baig