VB.NET PROGRAM TO ADD TWO NUMBERS / INTEGERS USING FUNCTION
Module Module1 Sub Main() Dim x, y, result As Integer Console.WriteLine("*** www.ProgrammingPosts.blogspot.com ***") Console.WriteLine(">>> VB.NET Console program to add two integers <<<") Console.Write(" Enter the first number to be added: ") x = Convert.ToInt32(Console.ReadLine()) Console.Write(" Enter the second number to be added: ") y = Convert.ToInt32(Console.ReadLine()) result = Sum(x, y) Console.Write(Environment.NewLine & " The sum of two numbers is:" & result) Console.ReadLine() End Sub Function Sum(ByVal a, ByVal b) As Integer Dim c As Integer c = a + b Return c End Function End Module
Sample Output:
No comments:
Post a Comment
Thanks for your comments.
-Sameer