Download presentation
Presentation is loading. Please wait.
Published byPauline Anthony Modified over 9 years ago
1
For…Next : Nested Loop X= 0 For i = 0 To 4 For j = 0 To i-1 X=X+(i+j-1) Next j Next i How many times the inner loop is executed? What is x at the end of this loop?
2
Nested For…Next : Execution i=0 j=0 -1 i=1 j=0 0 i=2 j=0 1 i=3 j=0 2 i=4 j=0 3 No. of times inner loop is executed 01234 x001313 5 8 12 15 19 24 30
3
For…Next : Exit X= 0 For i = 0 To 4 For j = 0 To i-1 If x > 5 Then Exit For End If x=x+(i+j-1) Next j Next I Exit from the inner loop
4
Do…Loop Do While logical expression Executable statement(s) Loop Do Executable statement(s) Loop Until logical expression
5
Do While…Loop
6
Do…Loop Until…
7
Do Loops Sum = 0 Kount = 0 Do While Kount <= 10 Sum = Sum + Kount Kount = Kount + 1 Loop Sum = 55 Kount = 11 Sum = 0 Kount = 0 Do Sum = Sum + Kount Kount = Kount + 1 Loop Until Kount > 10 Sum = 55 Kount = 11
8
Decimal to Binary : Do While Private Sub Command1_Click() Dim Deci As Integer Dim R As Byte, Bin As String Deci = Text1.Text Bin = "" Picture1.Cls If Deci = 0 Then Bin = Str(Deci) End If Do While Deci > 0 R = Deci Mod 2 Bin = Str(R) + Bin Deci = Deci \ 2 Loop Picture1.Print Bin End Sub
9
Decimal To Binary: Do…Until Private Sub Command3_Click() Dim Deci As Integer Dim R As Byte, Bin As String Deci = Text1.Text Bin = "" Picture1.Cls Do R = Deci Mod 2 Bin = Str(R) + Bin Deci = Deci \ 2 Loop Until Deci = 0 Picture1.Print Bin End Sub
10
File Handling Files are used for large data input/output Create a.txt file called CarData by using Notepad (or ASCII file using other software) with following contents “Suzuki”, 3, 4 “Toyota”, 5, 7 “Honda”, 4, 15
11
File Handling Files must be Open ed before any read/write operation. Files must be Close d after any read/write operation Syntax Open “CarData” For Input As #138 Opens a file called CarData.txt for read- only and this file will be called #138 The file reference number can be from 1 to 255
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.