Assignment No. – 01
Program on if - else :-
Module
decisionskb
Sub Main()
'local variable definition '
Dim a As Integer = 100
' check the boolean condition '
If (a = 10) Then
' if condition is true then print the
following '
Console.WriteLine("Value of a is
10") '
ElseIf (a = 20) Then
'if else if condition is true '
Console.WriteLine("Value of a is
20") '
ElseIf (a = 30) Then
'if else if condition is true
Console.WriteLine("Value of a is
30")
Else
'if none of the conditions is true
Console.WriteLine("None of the
values is matching")
End If
Console.WriteLine("Exact value of a
is: {0}", a)
Console.ReadLine()
End Sub
End
Module
Output :-
None of the values is matching
Exact value of a is: 100
Program on Select Case :-
Module decisionskb
Sub Main()
'local variable definition
Dim grade As Char
grade = "B"
Select grade
Case "A"
Console.WriteLine("Excellent!")
Case "B", "C"
Console.WriteLine("Well done")
Case "D"
Console.WriteLine("You passed")
Case "F"
Console.WriteLine("Better try again")
Case Else
Console.WriteLine("Invalid grade")
End Select
Console.WriteLine("Your grade is {0}", grade)
Console.ReadLine()
End Sub
End Module
Output :-
Well done
Your grade is B
Program
on Do - While :-
Module loopskb
Sub Main()
' local variable definition
Dim a As Integer = 10
'do loop execution
Do
Console.WriteLine("value of a: {0}", a)
a = a + 1
Loop While (a < 20)
Console.ReadLine()
End Sub
End Module
Output :-
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
Program on For loop :-
Module loopskb
Sub Main()
Dim a As Byte
' for loop execution
For a = 10 To 20
Console.WriteLine("value of a: {0}", a)
Next
Console.ReadLine()
End Sub
End Module
Output :-
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
value of a: 20
No comments:
Post a Comment