Professional Documents
Culture Documents
ASSIGNMENT
ON
DOT NET TECHNOLOGY
BACHELOR OF COMPUTER APPLICATION
From
Pt. Ravishankar shukla University Raipur (C.G.)
Final Year
Year: 2022-2023
Guided by Submitted by
Mrs. Minal Chaphekar Ashish Sahu
Asst. Prof. (Comp. Science Dept.) CLASS-BCA3
Submitted to
Pragati College Raipur (C.G)
Pt. Ravishankar Shukla University Raipur (C.G)
ACKNOWLEDGEMENT
No work can be completed successfully without the help, inspiration
an encouragement by the elders and seniors. So my heartily thanks
to all of them who helped me while preparing this assignment. I
would begin by thanking to my parents who provided me the
required support for completing this job.
I Acknowledgement and thanks for the help
received form Mrs. Minal Chaphekar our “ASSIGNMENT
INCHARGE” and classmates who guided me to complete this
assignment.
1
CERTIFICATE OF APPROVAL
CERTIFICATE OF EVALUATION
This is to certify that the project work entitled is “Dot Net” carried
out by Ashish Sahu a student of “BCA-3 YEAR” at PRAGATI
COLLEGE, after proper evaluation and examination, is hereby
approved as a satisfactory manner for its acceptance as a requisite
for the award of degree of “BCA-3 YEAR” during the year 2022-
2023 form PT. RAVISHANKAR SHUKLA UNIVERSITY,
RAIPUR(C.G.).
3
Internal Examiner External Examiner
4
IND
EX
S. Name of Program Page Rema
No. no. rk
12 Design the form to input radius of a circle and find its 24-25
circumference and area.
13 Design the form to input length in centimeter and convert it 26
into
meter.
14 Design the form to input temperature in Celsius and convert it 27
into Fahrenheit.
15 Design the form to input Principal amount, Time, Rate and 28-29
calculate Simple Interest and compound interest show result
information in msgbox.
16 Design the form and write a program to sort array element in 30-31
ascending order
17 Design the form and write a program to insert an element in an 32-33
array.
18 Design the form and write a program to delete an element from 34-35
an array at specified position.
19 Design the form and write a program to print all unique 36-37
elements in the array.
20 Design a form to check whether a number is PRIME or NOT 38-39
using input box and msgbox.
21 Write a program to print Fibonacci series up to n terms. 40-41
22 Design the following form when user clicks on Radio Button 42-43
then selectCheckbox.
6
7
23 Design the Digital watch using Timer Control. 44-45
8
29 Design from that shows the functionality of listbox 56-58
34 Write a class having name Calculate that uses static overloaded 67-68
function to calculate area of circle, area of rectangle and area
of triangle.
35 WAP to check whether a given number is neon or not using 69-70
user define function
36 WAP to check whether a given number is Niven or not 71-72
using procedure
37 WAP to check whether a given number is Duck number or not . 73-74
9
39 Write a program to find first and last digit of any number. 77-78
40 Write a program to enter any number and print its reverse. 79-80
10
Q1.Write a program to find maximum between three numbers.
CODE –
Module Module1
Sub Main()
Dim a, b, c As Integer
Console.WriteLine("Enter the first number - ")
a = Console.ReadLine()
Console.WriteLine("Enter the second number - ")
b = Console.ReadLine()
Console.WriteLine("Enter the third number - ")
c = Console.ReadLine()
If (a > b) Then
If (a > c) Then
Console.WriteLine("A is the greatest number")
Else
Console.WriteLine("C is the greatest number")
End If
Else
If (b > c) Then
Console.WriteLine("B is the greatest number")
Else
Console.WriteLine("C is the greatest number")
End If
End If
Console.ReadLine()
11
End Sub
End Module
OUTPUT –
12
Q.1 Write a program to check whether a number is negative,
positive or zero.
CODE –
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If (0 < TextBox1.Text) Then
MsgBox("Number is positive")
ElseIf (0 > TextBox1.Text) Then
MsgBox("number is negative")
Else
MsgBox("number is zero")
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
End
End Sub
End Class
Output –
13
Q.2 Write a program to check whether a year is leap year or not.
CODE –
Module Module1
Sub Main()
Dim year As Integer
Console.WriteLine("Enter the year : -")
year = Console.ReadLine()
If (year Mod 4 = 0 And year Mod 100 <> 0 Or year Mod 400 = 0 Then
Console.WriteLine("this is leap year")
Else
Console.WriteLine("this is not leap year")
End If
Console.ReadLine()
End Sub
End Module
OUTPUT -
14
Q.3 Write a program to check whether a character is alphabet or
not.
CODE -
Module Module1
Sub Main()
Dim c As Char
Dim i As Integer
Console.WriteLine("*** Program to check character is Alphabet or Not *
**")
Console.WriteLine()
Console.Write(" Enter a character :- ")
c = Console.ReadLine()
i = Asc(c)
If ((i >= 97 And i <= 122) Or (i >= 65 And i <= 90)) Then
Console.WriteLine(" {0} is a Character", c)
Else
Console.WriteLine(" {0} is not a Character", c)
End If
Console.ReadLine()
End Sub
End Module
OUTPUT -
15
Q.4
16
Write a program to find all roots of a quadratic equation.
CODE -
Module Module1
Sub Main()
Dim a, b, c, r1, r2 As Single
Console.WriteLine("*** Program to find all Roots of a Quadration
Equation ***")
Console.WriteLine()
Console.Write(" Enter the value of A :- ")
a = Console.ReadLine()
Console.Write(" Enter the value of B :- ")
b = Console.ReadLine()
Console.Write(" Enter the value of C :- ")
c = Console.ReadLine()
Console.WriteLine()
Dim d As Integer = b ^ 2 - 4 * a * c
If d = 0 Then
Console.WriteLine(" Roots are real and equal.")
r1 = -b / (2 * a)
Console.WriteLine(" Root1 = Root2 = {0}", r1)
ElseIf d > 0 Then
Console.WriteLine(" Roots are real and different.")
r1 = (-b + d ^ 0.5) / (2 * a)
r2 = (-b - d ^ 0.5) / (2 * a)
Console.WriteLine(" Root1 = {0}, Root2 = {0}", r1, r2)
17
Else
18
Console.WriteLine(" Roots are complex and different.")
Console.Write(" Root1 = ")
Console.WriteLine(-b / (2 * a) & "+" & (d * -1) ^ 0.5 / (2 * a) & "i")
Console.Write(" Root2 = ")
Console.WriteLine(-b / (2 * a) & "-" & (d * -1) ^ 0.5 / (2 * a) & "i")
End If
Console.ReadLine()
End Sub
End Module
OUTPUT -
19
Q.5 Design an application to input marks of five subjects physics,
chemistry, biology, mathematics and computer. Calculate
percentage and grade according to following: Percentage>=90% :
grade A Percentage>=80% : grade B Percentage>=70% : grade C
Percentage>=60% : grade C Percentage>=40% : grade E
Percentage.
CODE :
20
number1 = TextBox1.Text
21
number2 = TextBox2.Text
number3 = TextBox3.Text
number4 = TextBox4.Text
number5 = TextBox5.Text
total = number1 + number2 + number3 + number4 + number5
Dim percentage As Integer
percentage = total / 5
TextBox6.Text = percentage
If (percentage >= 90) Then
TextBox7.Text = "A"
ElseIf (percentage >= 80) Then
TextBox7.Text = "B"
ElseIf (percentage >= 70) Then
TextBox7.Text = "C"
ElseIf (percentage >= 60) Then
TextBox7.Text = "D"
ElseIf (percentage >= 40) Then
TextBox7.Text = "E"
Else
TextBox7.Text = "F"
End If
End Sub
End Class
22
OUTPUT -
23
Q.6 Design an application to input basic salary of an employee
and Gross salary according to following:
Basic Salary
<=10000 :HRA=20%,DA=80% Basic
Salary <=20000 :HRA=25%,DA=90%
Basic Salary >10000 :HRA=30%,DA=95%
CODE -
Public Class Form1
Dim BS, hra, da, gs As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
BS = InputBox("Basic Salary")
TextBox1.Text = BS
24
End Sub
25
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
If BS <= 10000 Then
hra = BS * 20 / 100
da = BS * 80 / 100
ElseIf BS <= 20000 Then
hra = BS * 25 / 100
da = BS * 90 / 100
Else
hra = BS * 30 / 100
da = BS * 95 / 100
End If
gs = BS + hra + da
TextBox2.Text = gs
End Sub
End Class
OUTPUT -
26
8 Design an application which is similar to login from.
CODE -
27
MsgBox("account not exits", MsgBoxStyle.Critical)
End If
End Sub
End Class
28
Q.9 WAP using checkbox for the following font effects.
Bold , Italic , Underline , Increase font size ,Decrease font size
,Font color.
CODE : -
29
Label1.Font = New Font(Label1.Font.FontFamily, 12,
FontStyle.Regular)
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Dim Name As String
Name = Label1.Text
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As
EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Bold)
Else
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Regular)
End If
End Sub
Private Sub CheckBox2_CheckedChanged(sender As Object, e As
EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked Then
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Italic)
Else
Label1.Font = New Font(Label1.Font.FontFamily, Label1.Font.Size,
FontStyle.Regular)
End If
End Sub
30
Q.10 Design the form that calculate Sum, Multiplication, Division
and Subtraction of two number.
CODE :
31
End Sub
32
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
TextBox5.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles
End Class
OUTPUT -
33
Q. 11 Design Simple calculator.
CODE –
OUTPUT -
I P a g e 37 |
Q.12 Design the form to input radius of a circle and find its
circumference and area.
CODE : -
I P a g e 38 |
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
End Sub
End Class
OUTPUT -
I P a g e 39 |
Q.13 Design the form to input length in centimeter and convert it
into meter.
CODE :
OUTPUT –
I P a g e 40 |
Q.14 Design the form to input temperature in Celsius and convert
it into Fahrenheit.
CODE -
Public Class Form1
End Class
OUTPUT -
I P a g e 41 |
Q.15 Design the form to input Principal amount, Time, Rate and
calculate Simple Interest and compound interest show result
information in msgbox.
CODE : -
Public Class Form1
I P a g e 42 |
a = Ap - p
MsgBox("compound intrest is : " & si)
End Sub
End Class
OUTPUT -
I P a g e 43 |
Q.16 Design the form and write a program to sort array element
in ascending order.
CODE :
End Class
OUTPUT –
I P a g e 45 |
Q.17 Design the form and write a program to insert an element
in an array.
CODE :-
I P a g e 47 |
Q.18 Design the form and write a program to delete an
element from an array at specified position.
CODE :
OUTPUT –
I P a g e 49 |
Q.19 Design the form and write a program to print all unique
elements in the array.
CODE : -
OUTPUT -
I P a g e 51 |
Q.20 Design a form to check whether a number is PRIME or
NOT using input box and msgbox.
CODE : -
I P a g e 52 |
Next
If (flay <> 0) Then
TextBox2.Text = "not prime number"
MsgBox("not prime number")
Else
TextBox2.Text = "prime number"
MsgBox("prime number")
End If
End Sub
End Class
OUTPUT –
I P a g e 53 |
Q.21 Write a program to print Fibonacci series up to n terms.
CODE –
Module Module1
Sub Main()
Dim length, number1, number2, total As Integer
Console.WriteLine("Enter the length ")
length = Console.ReadLine()
Console.WriteLine("Enter the first and second number")
number1 = Console.ReadLine()
number2 = Console.ReadLine()
Console.Write(number1 & " " & number2 & " ")
For i = 1 To length - 1
total = number1 + number2
Console.Write(total & " ")
number1 = number2
number2 = total
Next
Console.ReadLine()
End Sub
End Module
I P a g e 54 |
OUTPUT –
I P a g e 55 |
Q.22 Design the following form when user clicks on Radio Button
then select Checkbox.
CODE : -
OUTPUT –
I P a g e 57 |
Q.23 Design the Digital watch using Timer Control.
CODE
Public Class Form1
End Class
OUTPUT –
I P a g e 59 |
Q.24 Design the following form using horizontal scrollbar. In this,
when user click on particular scrollbar then back color of shape
will be changed to Red, Green & Blue color.
CODE –
I P a g e 60 |
End Sub
End Class
OUTPUT -
I P a g e 61 |
Q.25 Design the following form using vertical scrollbar. In this,
when user click on particular scrollbar then back color of shape
will be changed to Red, Green &Blue color.
CODE -
I P a g e 62 |
Panel1.BackColor = Color.Red
End Sub
Private Sub VScrollBar2_Scroll(sender As Object, e As ScrollEventArgs)
Handles VScrollBar2.Scroll
Panel1.BackColor = Color.Green
End Sub
Private Sub VScrollBar3_Scroll(sender As Object, e As ScrollEventArgs)
Handles VScrollBar3.Scroll
Panel1.BackColor = Color.Blue
End Sub
End Class
OUTPUT –
I P a g e 63 |
Q.26 Design the form with different controls.
CODE :
Public Class Form1
I P a g e 66 |
Q.27 WAP for Exception handling of throwing an exception when
dividing by zero condition occur during arithmetic operation.
CODE -
Module Module1
Sub Main()
Dim number1, number2, div As Integer
number1 = 9
number2 = 0
Console.WriteLine("number1 = " & number1 & " number2 = " & number2)
Try
div = number1 / number2
Catch ex As Exception
Console.WriteLine("Can't divided by ZERO")
End Try
Console.WriteLine(div)
Console.ReadLine()
End Sub
End Module
OUTPUT -
I P a g e 67 |
Q.28 WAP in vb.net such that throw a user define exception when
Temperature is zero
CODE –
Module Module1
Public Class erroeHandleeee : Inherits Exception
Sub New()
MyBase.New(" Error accured")
End Sub
End Class
Sub Main()
Dim temp As Integer
Console.WriteLine()
Console.Write(" Enter the temp : ")
temp = Console.ReadLine
Console.WriteLine()
Try
If temp <> 0 Then
Console.WriteLine(" temperature is " & temp)
Else
Throw New erroeHandleeee()
End If
Catch ex As erroeHandleeee
Console.WriteLine(" user defined error handled")
End Try
Console.ReadLine()
End Sub
I P a g e 68 |
End Module
OUTPUT -
I P a g e 69 |
Q.29 Design from that shows the functionality of listbox.
CODE :
Public Class Form1
Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Yellow")
ListBox1.Items.Add("black")
ListBox1.Items.Add("white")
ListBox1.Items.Add("green")
ListBox2.Items.Add("car")
ListBox2.Items.Add("bike")
ListBox2.Items.Add("bus")
ListBox2.Items.Add("train")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
ListBox2.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End Sub
I P a g e 70 |
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
ListBox1.Items.Add(ListBox2.SelectedItem)
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
ListBox2.Items.AddRange(ListBox1.Items)
ListBox1.Items.Clear()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
ListBox1.Items.AddRange(ListBox2.Items)
ListBox2.Items.Clear()
End Sub
OUTPUT -
I P a g e 72 |
Q.30 Write a vb.net programto show data in Data grid view.
CODE : -
Public Class Form1
End Sub
End Class
I P a g e 73 |
OUTPUT -
I P a g e 74 |
Q. 31 Create following table Student (id,name ,course ,DOB
,address) Write vb.net application to
1. Add records
2. View all the records.
CODE : -
Public Class Form1
I P a g e 75 |
End Class
OUTPUT –
I P a g e 76 |
Q.32 Develop a project which displays the student information in
the relevant fields from the database which already exists.
CODE :
Public Class Form1
I P a g e 77 |
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Table1BindingSource.MoveFirst()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
Table1BindingSource.MoveLast()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
Table1BindingSource.MoveNext()
End Sub
End Class
OUTPUT –
I P a g e 78 |
Q.33 Define structure student. Structure student has data
members for storing name, rollno ,name of three subjects and
marks. Write member function to store and print data.
CODE –
Module Module1
Structure Struct
Public name As String
Public rollno As Integer
Public maths As Integer
Public physics As Integer
Public chemistry As Integer
Public Sub input()
Console.WriteLine("Ente the student details ")
Console.WriteLine()
Console.Write("name : ")
name = Console.ReadLine()
Console.Write("Roll no. : ")
rollno = Console.ReadLine()
Console.Write("Maths : ")
maths = Console.ReadLine()
Console.Write("Physics : ")
physics = Console.ReadLine()
Console.Write("Chemistry : ")
chemistry = Console.ReadLine
End Sub
Public Sub display()
I P a g e 79 |
Console.WriteLine(" ")
Console.WriteLine()
Console.WriteLine("student marksheet")
Console.WriteLine("name : " & name)
Console.WriteLine("Roll no. : " & rollno)
Console.WriteLine("Maths : " & maths)
Console.WriteLine("Physics : " & physics)
Console.WriteLine("Chemistry : " & chemistry)
Console.ReadLine()
End Sub
End Structure
Sub Main()
Dim st As Struct
st.input()
st.display()
End Sub
End Module
OUTPUT –
I P a g e 80 |
Q.34 Write a class having name Calculate that uses static
overloaded function to calculate area of circle, area of
rectangle and area of triangle.
CODE –
Module Module1
Public Class Calculate
Shared Sub area(ByVal r As Integer)
Console.WriteLine()
Console.Write("Area of Circle :- ")
Console.WriteLine(Math.PI * r * r)
End Sub
Shared Sub area(ByVal l As Double, ByVal h As Double)
Console.WriteLine()
Console.Write("Area of Rectangle :- ")
Console.WriteLine(l * h)
End Sub
Shared Sub area(ByVal b As Integer, ByVal p As Integer)
Console.WriteLine()
Console.Write("Area of Triangle :- ")
Console.WriteLine(1 / 2 * b * p)
End Sub
End Class
Sub Main()
Dim obj As Calculate = New Calculate()
Calculate.area(5)
Calculate.area(5.0, 3.0)
I P a g e 81 |
Calculate.area(4, 3)
Console.ReadLine()
End Sub
End Module
OUTPUT –
I P a g e 82 |
Q.35 WAP to check whether a given number is neon number or
not using user define function.
CODE –
Module Module1
Dim n As Integer
Dim sqaure As Integer
Dim sum As Integer
Sub Main()
Console.WriteLine("*** check given number is neon number or not ***")
Console.WriteLine()
Console.Write(" Enter a no : ")
n = Console.ReadLine()
sqaure = n * n
display()
End Sub
Function display()
While sqaure > 0
sum = sum + sqaure Mod 10
sqaure = sqaure \ 10
End While
If sum = n Then
Console.WriteLine(" neon number")
Else
Console.WriteLine(" not a neon number")
End If
I P a g e 83 |
Console.ReadLine()
Return 0
End Function
End Module
OUTPUT -
I P a g e 84 |
Q.36 WAP to check whether a given number is Niven number or
not using procedure.
CODE –
Module Module1
Sub Main()
Dim num As Integer
Dim remaining = 0, sum = 0, n As Integer
Console.WriteLine("*** check given number is Niven number or not
***")
Console.WriteLine()
Console.Write(" Enter number : ")
num = Console.ReadLine()
n = num
While (num > 0)
remaining = num Mod 10
sum = sum + remaining
num = num \ 10
End While
If (n Mod sum = 0) Then
Console.WriteLine(" niven number")
Else
Console.WriteLine(" not a niven number")
End If
Console.ReadLine()
End Sub
I P a g e 85 |
End Module
OUTPUT –
I P a g e 86 |
Q.37 WAP to check whether a given number is duck number or
not.
CODE –
Sub Main()
Dim n, i, r As Integer
r=0
Console.WriteLine("*** Check Given Number is Duck number or Not ***")
Console.WriteLine()
Console.Write("Enter a no : ")
n = Console.ReadLine
While n <> 0
i = n Mod 10
If i = 0 Then
r=r+1
End If
n = n \ 10
End While
If r >= 1 Then
Console.WriteLine("duck number")
Else
Console.WriteLine("not a duck number")
End If
Console.ReadLine()
End Sub
End Module
I P a g e 87 |
OUTPUT –
I P a g e 88 |
Q.38 WAP to check whether a given number is spy number or
not.
CODE –
Module Module1
Sub Main()
Dim num, product, sum, lastdigit As Integer
product = 1
sum = 0
Console.WriteLine("*** check given number is spy number or not ****")
Console.WriteLine()
Console.Write(" Enter the number to check : ")
num = Console.ReadLine()
While (num > 0)
lastdigit = num Mod 10
sum = sum + lastdigit
product = product * lastdigit
num = num / 10
End While
If sum = product Then
Console.WriteLine(" The given number is a spy number")
Else
Console.WriteLine(" The given number is not spy number")
End If
Console.ReadLine()
I P a g e 89 |
End Sub
End Module
OUTPUT -
I P a g e 90 |
Q.39 Write a program to find first and last digit of any number.
CODE –
Module Module1
Dim n As Integer
Sub Main()
Console.WriteLine()
Console.Write(" Enter number : ")
n = Console.ReadLine
Console.WriteLine()
Console.WriteLine(" First digit is " & firstDigit(n) & " and " & "last digit is "
& lastDigit(n))
Console.ReadLine()
End Sub
Function firstDigit(n)
While (n >= 10)
n \= 10
End While
Return n
End Function
Function lastDigit(n)
Return (n Mod 10)
End Function
End Module
I P a g e 91 |
OUTPUT -
I P a g e 92 |
Q. 40 Write a program to enter any number and print its reverse.
CODE –
Module Module1
Sub Main()
Dim number As Integer = 0
Dim remainder As Integer = 0
Dim reverse As Integer = 0
Console.WriteLine(" *** Reverse number: *** ")
Console.Write("Enter the number: ")
number = Integer.Parse(Console.ReadLine())
While (number > 0)
remainder = number Mod 10
reverse = reverse * 10 + remainder
number = number / 10
End While
Console.WriteLine("Reverse: {0}", reverse)
Console.ReadLine()
End Sub
End Module
I P a g e 93 |
OUTPUT –
I P a g e 94 |
Q.41 WAP to check whether a given number is Armstrong or not.
CODE –
Module module1
Sub Main(args As String())
Dim n As Integer, r, temp As Integer, sum As Integer = 0
Console.WriteLine("*** Check given number is Armstrong or not ***")
Console.WriteLine()
Console.Write(" Enter the Number : ")
n = Integer.Parse(Console.ReadLine())
temp = n
While n > 0
r = n Mod 10
sum = sum + (r * r * r)
n = n \ 10
End While
If temp = sum Then
Console.Write(" Armstrong Number.")
Else
Console.Write(" Not Armstrong Number.")
End If
Console.ReadLine()
End Sub
End Module
I P a g e 95 |
OUTPUT -
I P a g e 96 |
Q.42 WAP to enter any number and check whether the no.
is palindrome or not.
CODE -
Module Module1
Sub Main()
Console.WriteLine("*** check numbers is palindrome number or not ***")
Console.WriteLine()
Dim n, r, temp As Integer, sum As Integer = 0
Console.Write(" Enter the Number: ")
n = Integer.Parse(Console.ReadLine())
temp = n
While n > 0
r = n Mod 10
sum = (sum * 10) + r
n = n / 10
End While
If temp = sum Then
Console.Write(" Number is Palindrome.")
Else
Console.Write(" Number is not Palindrome")
End If
Console.ReadLine()
I P a g e 97 |
End Sub
End Module
OUTPUT –
I P a g e 98 |
Q.43 WAP to calculate factorial of a number using user define
procedure.
CODE –
Module Module1
Dim i, number As Integer, fact As Integer = 1
Sub Main()
Console.WriteLine("*** Calculate Factorial of given number ***")
Console.WriteLine()
Console.Write(" Enter number : ")
number = Integer.Parse(Console.ReadLine())
fac()
Console.ReadLine()
End Sub
Sub fac()
For i = 1 To number
fact = fact * i
Next
Console.WriteLine()
Console.WriteLine(" Factorial of " & number & " is :" & fact)
End Sub
End Module
I P a g e 99 |
OUTPUT -
I P a g e 100 |
Q.44 Create a class circle with data member radius; provide
member function to calculate area. Define a class sphere
from class circle, provide member function to calculate area
class cylinder from class sphere with additional data member
for height and member function to calculate volume.
CODE -
Module Module1
Class circle
Public radius As Integer
Sub area(ByVal r As Integer)
radius = r
Console.WriteLine("Circle class")
Console.Write(" Area of Circle : ")
Console.WriteLine(Math.PI * radius * radius)
End Sub
End Class
Class sphere
Inherits circle
Sub display()
Console.WriteLine("sphere class")
Console.Write(" Area of Sphere : ")
Console.WriteLine(Math.PI * radius * radius * 4)
End Sub
End Class
Class Cylinder
Inherits sphere
Sub display2(ByVal h1 As Integer)
I P a g e 101 |
Dim h As Integer = h1
Console.WriteLine("Cylinder class")
Console.Write(" Volume of Cylinder : ")
Console.WriteLine(Math.PI * radius * h)
End Sub
End Class
Sub Main()
Dim obj As Cylinder = New Cylinder()
obj.area(5)
obj.display()
obj.display2(6)
Console.ReadLine()
End Sub
End Module
OUTPUT –
I P a g e 102 |