Posts

Showing posts from February, 2017

Print Greatest Number out of 3 numbers

Module Module1 Sub Main() Dim num1, num2, num3 As Integer Console.WriteLine("Enter the first number") num1 = Console.ReadLine Console.WriteLine("Enter the second number") num2 = Console.ReadLine Console.WriteLine("Enter the third number") num3 = Console.ReadLine If num1 > num2 And num1 > num3 Then Console.WriteLine(num1 & " is the greatest number") ElseIf num2 > num1 And num2 > num3 Then Console.WriteLine(num2 & " is the greatest number") ElseIf num1 = num2 And num2 = num3 Then Console.WriteLine("Oops ! you have enetered a number thrice. So ! no greater number found") Else Console.WriteLine(num3 & " is the greatest number") End If Console.ReadKey() End Sub End Module

Greatest of two numbers

Module Module1 Sub Main() 'This program checks the greatest number ans shows equal if input numbers are equal. Dim num1, num2 As Integer 'declaring the numbers Console.WriteLine("Enter the first number") 'asking to enter the first number num1 = Console.ReadLine Console.WriteLine("Enter second second number") ' asking to enter the second number num2 = Console.ReadLine 'if conditional If num1 > num2 Then Console.WriteLine(num1 & " is the greatest number.") ElseIf num1 = num2 Then Console.WriteLine("Oops ! you have entered the same number twice") Else Console.WriteLine(num2 & " is the greatest number") End If Console.ReadLine() End Sub End Module

Sum of two numbers

Module Module1 Sub Main() Dim number1 As Integer Dim number2 As Integer Dim sum As Integer 'declaration above can also be defined in a single line instead of three lines as 'Dim number1, number2,sum as Integer 'We can separate them by comma as they share the common data-type Console.WriteLine("Enter the first number") number1 = Console.ReadLine Console.WriteLine("Enter the second number") number2 = Console.ReadLine sum = number1 + number2 Console.WriteLine("The sum of the two numbers is " & sum) Console.ReadKey() End Sub End Module

Program to enter value into the array and print

Module Module1 Sub Main() 'program to input value into array and print it out Dim arr(5) As Integer 'assigning array with integer in it Dim index As Integer 'assigning the counter to be used in the loop Console.WriteLine("Enter the values into the array") For index = 1 To 5 arr(index) = Console.ReadLine Next Console.WriteLine("The elements inside the aaray are: ") For index = 1 To 5 Console.Write(arr(index) & " ") Next Console.ReadKey() ' this line of the code holds the window to see the output End Sub End Module

Area of Circle

Module Module1 Sub Main() 'program to find the area of the circle Dim radius, Area, pi As Single Console.Write("Enter the radius of the circle: ") radius = Console.ReadLine pi = 3.14 Area = pi * radius * radius Console.WriteLine("The area of the circle is: " & Area) Console.ReadKey() 'This line of code is used to hold the output window to see the output End Sub End Module

Area of Square

Module Module1 Sub Main() 'Program to find the area of the square Dim length, Area As Integer Console.Write("Enter the length of the square: ") length = Console.ReadLine Area = length * length Console.WriteLine("The area of the square is: " & Area) Console.ReadKey() 'This line of code is used to hold the output window to see the output End Sub End Module

Area of Rectangle

Module Module1 Sub Main() 'Program to find the area of the rectangle Dim length, breadth, Area As Integer Console.Write("Enter the length of the rectangle: ") length = Console.ReadLine Console.Write("Enter the breadth of the rectangle: ") breadth = Console.ReadLine Area = length * breadth Console.WriteLine("The area of the rectangle is: " & Area) Console.ReadKey() 'This line of code is used to hold the output window to see the output End Sub End Module

Print Hello World in a message box

Module Module1 Sub Main() 'program to print "Hello World" in the output window Dim msg As String msg = "Hello World" MsgBox(msg) End Sub End Module

Print Hello World

Module Module1 Sub Main() 'program to print "Hello World" in the output window Dim msg As String msg = "Hello World" Console.WriteLine(msg) Console.ReadKey() End Sub End Module