Pages

Search This Blog

Sum by Function Overloading


Module SumByFuncOverloading

    Sub Main()
        Dim a, b, s1, s2 As Integer
        Console.Write("Enter the value of a: ")
        a = CInt(Console.ReadLine())
        Console.Write("Enter the value of b: ")
        b = CInt(Console.ReadLine())
        Console.WriteLine()
        Console.WriteLine("Display")
        Console.WriteLine("a= " + a.ToString())
        Console.WriteLine("b= " + b.ToString())
        'function overloading
        s1 = add(a)
        s2 = add(a, b)
        Console.WriteLine()
        Console.WriteLine("Sum1= " + s1.ToString())
        Console.WriteLine("Sum2= " + s2.ToString())
        Console.ReadLine()
    End Sub
    Function add(ByVal m As Integer) As Integer
        'adding 100 to m
        m += 100
        Return m
    End Function
    Function add(ByVal p As Integer, ByVal q As Integer) As Integer
        Return p + q
    End Function
End Module

2 comments: