Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Math.DivRem Method
Use the Math.DivRem method to calculate the quotient of two numbers and return the remainder.
Firstly, set dividend and divisor.
// dividend long dividend = 30; // divisor long divisor = 7;
Now, use the DivRem method.
long quotient = Math.DivRem(dividend, divisor, out rem);
Example
using System;
using System.Globalization;
class Demo {
static void Main() {
// remainder
long rem;
// dividend
long dividend = 98;
// divisor
long divisor = 9;
long quotient = Math.DivRem(dividend, divisor, out rem);
Console.WriteLine("{0} \ {1} = {2} and remainder = {3}", dividend, divisor, quotient, rem);
}
}
Output
98 \ 9 = 10 and remainder = 8
Advertisements