0% found this document useful (0 votes)
342 views5 pages

Practical No-6

The document contains code snippets in VB.Net to print prime numbers between 1 to 100 using a while loop, print even and odd numbers between 1 to 50 using a while loop, and demonstrate while and do loops to print numbers from 1 to 10. It includes the code, brief explanations, and expected output for each program.

Uploaded by

Akash Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
342 views5 pages

Practical No-6

The document contains code snippets in VB.Net to print prime numbers between 1 to 100 using a while loop, print even and odd numbers between 1 to 50 using a while loop, and demonstrate while and do loops to print numbers from 1 to 10. It includes the code, brief explanations, and expected output for each program.

Uploaded by

Akash Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical No-06

Name-Samruddhi Vitthal Kharoshe


Batch=S1
Roll No-2025

Q. 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:
Q.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:
Q. Write a program using while and 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:
 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

OUTPUT:

You might also like