4

Javascript program to Find Quotient and Remainder

 1 year ago
source link: https://www.geeksforgeeks.org/videos/javascript-program-to-find-quotient-and-remainder/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Javascript program to Find Quotient and Remainder

Javascript program to Find Quotient and Remainder
  • 40 Views
  • 08/10/2022

In this video, we will write a Javascript program to find quotient and remainder.

What is quotient?
In arithmetic operation a quotient is the quantity produced by the division of two numbers, and remainder define as the integer left over digit after dividing one integer by another.

For Example:
Input:
39 divide by 5 then

Output:
quotient = 7
remainder = 4

Here we see 3 different methods for find quotient and remainder:

1. Using Math.floor()
2. Using ~~operator/binary operator
3. Using Right shift >> 0 operator

1. Using Math.floor():

In first method we use Math.floor(). In Java script a Math.floor method is used to round off the number passed as a parameter to its nearest integer in downward direction of rounding i.e. towards the lesser value.

2. Using ~~ operator:

In JavaScript, we can get the quotient and remainder of a division using the bitwise operators. So we can get the quotient of a division using the ~~ operator, which converts the floating-point number to an integer, and we use “%” character to get a remainder.

3. Using Right shift:

A Right shift operator returns the signed number. By using this we can calculate the quotient and remainder of any numbers.

Program to find Quotient & Remainder in Javascript:
https://www.geeksforgeeks.org/find-quotient-and-remainder-by-dividing-an-integer-in-javascript/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK