ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to demonstrate the Math.DivRem() method

Here, we are going to demonstrate the Math.DivRem() method in VB.Net.
Submitted by Nidhi, on December 02, 2020

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.

Program/Source Code:

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 »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.