Presentation on theme: "Control Structure There are two kind of control structure in GWBASIC one is iteration/loop or repetitive and second make decision/condition. Iteration/Loop."— Presentation transcript:
1 Control StructureThere are two kind of control structure in GWBASIC one is iteration/loop or repetitive and second make decision/condition.Iteration/LoopThe Loop mean one or more statements execute many times is called Loop. Here control transfer always upward. There are two types of loops.For … NextWhile .. Wend
2 Control Structure For .. Next The for next loop allows programs to repeat a statement or statements, as long as a certain is number of times.SyntaxFor Variable = Start No. To Stop No. [ Step Increment No.]statement1statement2..Next
3 Control Structure While .. Wend The while loop allows programs to repeat a statement or series of statement, over and over, as long as a certain test condition is true.SyntaxWhile teststatement1statement2..Wend
4 Practical #15Write a program to calculate current value at five different resistance values are from 1 to 5 here constant voltage is 5 by using loops. Formula is I=V/R.
5 15 print “Current = Voltage / resistance “ 20 for r = 1 to 5 10 Key Off15 print “Current = Voltage / resistance “20 for r = 1 to 530 let v=5Let I = v / rprint I ; “=“ ; v ; “/” ; r60 next70 endOut Put10 CLS20 Print “Current = Voltage / resistance “30 r=140 While r <= 550 let v=560 Let I = v / r70 Print I ; “=“ ; v ; “/” ; r80 r=r+190 Wend100 End
6 Out Put Current Voltage Resistance ===================================