- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Math.DivRem() Method in C#
The Math.DivRem() method in C# is used to divide and calculate the quotient of two numbers and also returns the remainder in an output parameter.
Syntax
public static int DivRem (int dividend, int divisor, out int remainder); public static long DivRem (long dividend, long divisor, long remainder);
Let us now see an example to implement Math.DivRem() method −
Example
using System; public class Demo { public static void Main(){ int dividend = 30; int divisor = 7; int remainder; int quotient = Math.DivRem(dividend, divisor, out remainder); Console.WriteLine("Quotient = "+quotient); Console.WriteLine("Remainder = "+remainder); } }
Output
This will produce the following output −
Quotient = 4 Remainder = 2
Let us see another example to implement Math.DivRem() method −
Example
using System; public class Demo { public static void Main(){ long dividend = 767676765765765; long divisor = 7; long remainder; long quotient = Math.DivRem(dividend, divisor, out remainder); Console.WriteLine("Quotient = "+quotient); Console.WriteLine("Remainder = "+remainder); } }
Output
This will produce the following output −
Quotient = 109668109395109 Remainder = 2
Advertisements