DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
ARAVALI COLLEGE OF
ENGINEERING & MANAGEMENT
(Jasana Tigaon Road Greater Faridabad Haryana 121001)
[Link] LAB
LAB FILE
(2020 - 2023)
FOR
5TH Semester
Submitted To. Submitted By
Ms. Pratima Sharma. Aman Daswal
20BCA05
`
Sr No. Programs Date Signature
1. Program to Print Hello World
2. Write a Program on Arithmetic Operation
3. Write a Program on String concatenation
4. Write a Program to Find Area of Rectangle
5. Sum of Two Number Using by Function
6. Write a Program on Constructor
7. Write a Program on Class
8. Write a Program to Inheritance program
9. Write a Program on an Array
10. Write a Program on Destructor
Program 1
[Link] to Print Hello World
Syntax :-
Imports System
Module Module1
Sub Main()
[Link]("Hello World!")
End Sub
End Module
Output :-
Program 2
[Link] a Program on Arithmetic Operation
Syntax :-
Imports System
Public Class Test
Public Shared Sub Main()
Dim x, y as Integer
x = 10
y = 25
[Link]("Sum of x and y = " & (x+y))
[Link]("Substraction of x and y = " & (x-y))
[Link]("Multiplication of x and y = " & (x*y))
[Link]("Division of x and y = " & (x/y))
End Sub
End Class
Output :-
Program 3
3. Write a Program on String concatenation
Syntax :-
Module strings
Sub Main()
Dim fname, lname, fullname, greetings As String
fname = "Umesh"
lname = "Kumar"
fullname = fname + " " + lname
[Link]("Full Name: {0}", fullname)
End Sub
End Module
Output :-
Program 4
4. Write a Program to Find Area of Rectangle
Syntax :-
Imports System
Module Module1
Class Figure
Public length As Double
Public breadth As Double
End Class
Sub Main()
Dim Rectangle As Figure = New Figure()
Dim area As Integer
[Link] = 8
[Link] = 7
area = [Link] * [Link]
[Link]("Area of Rectangle is : {0}", area
End Sub
End Module
Output :-
Program 5
5. Write a Program to Sum of Two Number Using by Function
Syntax :-
Module Module1
Function AddNum( num1 As Integer, num2 As Integer) As Integer
Dim num3 As Integer = 0
num3 = num1 + num2
AddNum = num3
End Function
Sub Main()
Dim num1 As Integer = 0
Dim num2 As Integer = 0
Dim num3 As Integer = 0
num1=34
num2=65
[Link]("Enter number1: ",num1)
[Link]("Enter number2: ",num2)
num3 = AddNum(num1, num2)
[Link]("Addition is: {0}", num3)
End Sub
End Module
Output :-
Program 6
6. Write a Program on Constructor
Syntax :-
Imports System
Module Default_Const
Class Student
Public Name As String
Public Age As Integer
Public Sub New()
name = "Aman Daswal"
Age = 22
End Sub
End Class
Sub Main()
Dim Student As Student = New Student()
[Link](" Student Name is : {0}", [Link])
[Link](" Student Age is : {0}", [Link])
End Sub
End Module
Output :-
Program 7
7. Write a Program on Class
Syntax :-
Module Module1
Class Student
Public name As String
Public age As Integer
Public RollNo As String
End Class
Sub Main()
Dim obj As Student = New Student()
[Link] = "Umesh"
[Link] = 22
[Link] = "20BCA52"
[Link]([Link])
[Link]([Link])
[Link]([Link])
[Link]()
End Sub
End Module
Output :-
Program 8
8. Write a Program to Inheritance program
Syntax :-
Module Module1
Class PersonalInfo
Dim id As Integer
Dim name As String
Public Sub SetPersonalInfo(ByVal i As Integer, ByVal n As String)
id = i
name = n
End Sub
Public Sub PrintPersonalInfo()
[Link]("Id : {0}", id)
[Link]("Name : {0}", name)
End Sub
End Class
Class StudentResultInfo
Inherits PersonalInfo
Dim marks As Integer
Dim per As Double
Dim grade As String
Public Sub SetInfo(ByVal i As Integer, ByVal n As String, ByVal m As Integer, ByVal p As Double, ByVal
g As String)
SetPersonalInfo(i, n)
marks = m
per = p
grade = g
End Sub
Public Sub PrintInfo()
PrintPersonalInfo()
[Link]("Marks : {0}", marks)
[Link]("Per : {0}", per)
[Link]("Grade : {0}", grade)
End Sub
End Class
Sub Main()
Dim S As New StudentResultInfo()
[Link](10, "Umesh", 420, 50.6, "B")
[Link]()
End Sub
End Module
Output :-
Program 9
9. Write a Program on Constuct an Array
Syntax :-
Imports System
Module num_Array
Sub Main()
Dim i As Integer, Sum As Integer = 0
Dim marks() As Integer = {10, 20, 30, 40, 50, 60}
[Link](" Marks in 6 Subjects")
For i = 0 To [Link] - 1
[Link](" Marks {0}", marks(i))
Sum = Sum + marks(i) Next
[Link](" Grand total is {0}", Sum)
End Sub
End Module
Output :-
Progr
am 10
10. Write a Program on Destructor
Syntax :-
Module Module1
Class Sample
Public Sub New()
[Link]("Constructor called")
End Sub
Protected Overrides Sub Finalize()
[Link]("Destructor called")
End Sub
Public Sub SayHello()
[Link]("Hello World")
End Sub
End Class
Sub Main()
Dim obj As New Sample()
[Link]()
End Sub
End Module
Output :-