Swift Double quotientAndRemainder()

The quotientAndRemainder() method calculates the quotient and remainder of the division of numerator by denominator.

Example


quotientAndRemainder() Syntax

The syntax of the quotientAndRemainder() method is:

num.quotientAndRemainder(dividingBy: otherNumber)

Here, num is a numerator.


quotientAndRemainder() Parameters

The quotientAndRemainder() method takes one parameter

  • otherNumber - the dividing value (denominator)

quotientAndRemainder() Return Values

The quotientAndRemainder() method returns the quotient and remainder of the division of num by otherNumber.


Example: Swift Double quotientAndRemainder()

Output

(quotient: 75, remainder: 0)
(quotient: 194, remainder: 4)

Here, we have used the quotientAndRemainder() method to compute the quotient and remainder while the numerator is divided by the denominator.