jagomart
digital resources
picture1_Practical No 06


 114x       Filetype PDF       File size 0.07 MB       Source: aratideshmukh.files.wordpress.com


File: Practical No 06
practical no 6 implement a program for while do loops in vb net practical no 06 viii resources required additional if any web references are required x resources used additional ...

icon picture PDF Filetype PDF | Posted on 03 Feb 2023 | 2 years ago
Partial capture of text on file.
                                Practical No. 6: Implement a program for While, Do Loops in VB.NET. 
                Practical No 06 
                
                VIII. Resources required (Additional) 
                     -    If any web references are required. 
                
                X. Resources used (Additional) 
                     -     https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/while- 
                          end-while-statement 
                     -     https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/do- 
                          loop-statement 
                
                XI. Program Code 
                Write a program using While & Do loop in VB.Net 
                  For while loop. 
                     Module  Module1 
                
                             Sub Main() 
                                    Dim a As Integer = 1 
                                    While (a < 10) 
                                           Console.WriteLine(a)   
                                           a = a + 1 
                                    End While 
                                    Console.ReadLine() 
                             End  Sub 
                
                     End  Module 
                     Output: 
                                   1 
                                   2 
                                   3 
                                   4 
                                   5 
                                   6 
                                   7 
                                   8 
                                   9 
                  For Do loop. 
                     Module  Module1 
                
                             Sub Main() 
                                    Dim a As Integer =  1 
                                    Do 
                                           Console.WriteLine(a)   
                                           a = a + 1 
                                    Loop  While  (a<10) 
                                    Console.ReadLine() 
                             End Sub 
                     End Module 
                 GUI Application Development using VB.Net (22034)                                                                          Page 1 
                         Practical No. 6: Implement a program for While, Do Loops in VB.NET. 
                Output: 
                           1 
                           2 
                           3 
                           4 
                           5 
                           6 
                           7 
                           8 
                           9 
            
             XIII. Practical Related Questions 
                     
                1.  Differentiate between Do & While Loop statements in VB.Net 
                No                   Do Loop                    No                  While Loop 
                      In Do loop, the condition can be tested         In While loop, the condition can be 
                 1    at starting or ending as per               1    tested at starting only. 
                      requirement. 
                 2    For Do Loop two variation available        2    For While loop no such variations are 
                      Do While Loop & Do Until Loop                   available. 
                      Do While Loop statement can execute             
                      for finite number of iterations as long         While loop can execute for finite 
                 3    as condition of loop is true while Do      3    number of iterations as long as 
                      Until Loop statement can execute for            condition of loop is true. 
                      finite number of iterations as long as 
                      condition of loop is false. 
                 4    Loop keyword is used as termination        4    End keyword is used as termination 
                      statement for Do loops.                         statement for While loop. 
                      Dim index As Integer = 0                        Dim index As Integer = 0 
                      Do                                              While index <= 10 
                          Debug.Write(index & " ")                        Debug.Write(index & " ") 
                 5      index += 1                               5      index += 1 
                      Loop Until index > 10                           End While 
                                                                      
                      Debug.WriteLine("")                             Debug.WriteLine("") 
                      ' Output: 0 1 2 3 4 5 6 7 8 9 10                ' Output: 0 1 2 3 4 5 6 7 8 9 10 
            
                2.  Give the syntax of While & Do loop statements in VB.NET. 
                  While Loop: 
                    It executes a series of statements as long as a given condition is True. 
                    Syntax: 
                             While condition 
                                [ statements ] 
                                [ Continue While ] 
                                [ statements ] 
                                [ Exit While ] 
                                [ statements ] 
                             End While 
             GUI Application Development using VB.Net (22034)                                              Page 2 
                      Practical No. 6: Implement a program for While, Do Loops in VB.NET. 
                  Do Loop: 
                  It repeats the enclosed block of statements while a Boolean condition is True or until the 
                  condition becomes True. It could be terminated at any time with the Exit Do statement. 
                  Syntax: 
                         Do 
                           [ statements ] 
                           [ Continue Do ] 
                           [ statements ] 
                           [ Exit Do ] 
                           [ statements ] 
                         Loop { While | Until } condition 
           
           
           XIV. Exercise 
              1.  Write a program using While statement to print the prime numbers between 1 to 100. 
              Module Module1 
                 Sub Main() 
                   Dim i, j, c As Integer 
                   c = 0 
                   i = 2 
                   While (i <= 100) 
                     j = 2 
                     While (j < i) 
                       If (i Mod j = 0) Then 
                          Exit While 
                       ElseIf (i = j + 1) Then 
                          Console.WriteLine(i) 
                       End If 
                       j = j + 1 
                     End While 
                     i = i + 1 
                   End         While 
                   Console.ReadLine() 
                 End Sub 
              End Module 
           
           OUTPUT: 
            GUI Application Development using VB.Net (22034)                                  Page 3 
                      Practical No. 6: Implement a program for While, Do Loops in VB.NET. 
              2.  Write a program using While statement to print even-odd numbers between 1 to 50. 
                Module Module1 
           
                    Sub Main() 
                      Dim i As Integer = 1 
                      While (i <= 50) 
                        If ((i Mod 2) = 0) Then 
                           Console.WriteLine(i & " Even") 
                        Else 
                           Console.WriteLine(i & " Odd") 
                        End If 
                        i = i + 1 
                      End While 
                      Console.ReadLine() 
                    End Sub 
           
                  End Module 
              Output: 
            GUI Application Development using VB.Net (22034)                                  Page 4 
The words contained in this file might help you see if this file matches what you are looking for:

...Practical no implement a program for while do loops in vb net viii resources required additional if any web references are x used https docs microsoft com en us dotnet visual basic language reference statements end statement loop xi code write using module sub main dim as integer console writeline readline output...

no reviews yet
Please Login to review.