Arithmetic Operators
| Imports System.Console Module Module1 Sub Main() Dim x, y, z As Integer x = 30 y = 20 z = x + y WriteLine("Addition" & " = " & z) z = x - y WriteLine("Subtraction" & " = " & z) z = x * y WriteLine("Multiplication" & " = " & z) z = x / y WriteLine("Division" & " = " & z) Read() End Sub End Module |
The image below displays output from above code.
Concatenation Operators
| Imports System.Console Module Module1 Sub Main() Dim str1, str2, str3, str4 As String str1 = "Concatenation" str2 = "Operators" str3 = str1 + str2 WriteLine(str3) str4 = str1 & str2 WriteLine(str4) Read() End Sub End Module |
The image below displays output from above code.
Comparison Operators
| Imports System.Console Module Module1 Sub Main() Dim x, y As Integer WriteLine("enter values for x and y ") x = Val(ReadLine()) y = Val(ReadLine()) If x = y Then WriteLine("x is equal to y") ElseIf x < y Then WriteLine("x is less than y") ElseIf x > y Then WriteLine("x is greater than y") End If Read() End Sub End Module |
The image below displays output from above code.
Logical / Bitwise Operators
| Imports System.Console Module Module1 Sub Main() Dim x As Boolean x = Not 45 > 26 WriteLine("x not is false") ' x equals false x = Not 26 > 87 ' x equals True WriteLine("x not is true") Read() End Sub End Module |
The image below displays output from above code.
No comments:
Post a Comment