Home »
VB.Net »
VB.Net Programs
VB.Net program to demonstrate the Math.DivRem() method
By Nidhi Last Updated : November 11, 2024
Math.DivRem() method in VB.Net
Here, we will find the quotient and remainder using DivRem() method of Math class and then print the values of quotient and remainder on the console screen.
VB.Net code to demonstrate the Math.DivRem() method
The source code to demonstrate the Math.DivRem() method is given below. The given program is compiled and executed successfully.
'VB.Net program to demonstrate the
'Math.DivRem() method.
Module Module1
Sub Main()
Dim quotient As Integer = 0
Dim remainder As Integer = 0
Dim num1 As Integer = 0
Dim num2 As Integer = 0
Console.Write("Enter the value of num1: ")
num1 = Integer.Parse(Console.ReadLine())
Console.Write("Enter the value of num2: ")
num2 = Integer.Parse(Console.ReadLine())
quotient = Math.DivRem(num1, num2, remainder)
Console.WriteLine("Quotient is: {0}", quotient)
Console.WriteLine("Remainder is: {0}", remainder)
End Sub
End Module
Output:
Enter the value of num1: 17
Enter the value of num2: 5
Quotient is: 3
Remainder is: 2
Press any key to continue . . .
Explanation:
In the above program, we created four variables quotient, remainder, num1, and num2 which are initialized with 0. After that, we read the value of num1 and num2 from the user.
Console.WriteLine("Quotient is: {0}", quotient)
Console.WriteLine("Remainder is: {0}", remainder)
In the above code, we find the quotient and remainder using DivRem() of Math class and then printed the result on the console screen.
VB.Net Basic Programs »