0% found this document useful (0 votes)
75 views3 pages

PRACTICAL NO.16docx

The document contains code snippets for three programming exercises: 1) A program using simple and parameterized functions to add two numbers. It defines a simple show function and parameterized Add function. 2) A recursive function program to calculate the factorial of a number. It defines a Fact function that recursively calls itself. 3) A program to find the maximum of two numbers using a parameterized findmax function. It defines a findmax function that compares two parameters and returns the larger number.

Uploaded by

Akash Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views3 pages

PRACTICAL NO.16docx

The document contains code snippets for three programming exercises: 1) A program using simple and parameterized functions to add two numbers. It defines a simple show function and parameterized Add function. 2) A recursive function program to calculate the factorial of a number. It defines a Fact function that recursively calls itself. 3) A program to find the maximum of two numbers using a parameterized findmax function. It defines a findmax function that compares two parameters and returns the larger number.

Uploaded by

Akash Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PRACTICAL NO-16

NAME-Samruddhi Vitthal Kharoshe

ROLL NO-2025

BATCH-S1

Q .Write a program using simple function and parameterized function.

Module Module1
Sub Main()
show()
Dim a, b As Integer
Console.WriteLine("Enter Two Numbers")
a = Console.ReadLine()
b = Console.ReadLine()
Add(a, b)
Console.WriteLine("Addition is = " & Add(a, b))
Console.ReadLine()
End Sub
Public Function show()
Console.WriteLine("This is Simple Function")
End Function
Public Function Add(ByVal i As Integer, ByVal j As Integer)
Dim sum As Integer
sum = i + j
Return sum
End Function
End Module
Q.Implement a program for recursion using a function

Module Module1
Sub Main()
Dim n As Integer
Console.WriteLine("Enter Number=")
n = Console.ReadLine()
Console.WriteLine("Result=")
Console.WriteLine(Fact(n))
Console.ReadLine()
End Sub
Function Fact(ByVal n As Integer)
If n = 0 Then
Fact = 1
Else
Fact = n * Fact(n - 1)
End If
End Function
End Module
Q.write a program to identify maximum number using parameterized
function

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a, b As Integer
Dim res As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
Call findmax(a, b)
res = findmax(a, b)
MessageBox.Show("Maximum Number is" & res)
Console.ReadLine()
End Sub
Private Function findmax(ByVal num1 As Integer, ByVal num2 As Integer)
Dim result As Integer
If (num1 > num2) Then
result = num1
Else
result = num2
End If
findmax = result
End Function
End Class

You might also like