Use remainder method to find the remainder in dart:
To find the remainder after one number divides another. It is called remainder() and defined in Number class. In this post, I will show you how to use remainder function with an example.
Definition of remainder:
remainder() function is defined as below:
Number.remainder(num)
num is the divisor.
Return value:
This method returns the remainder of a divisor.
Example program:
Below is the complete dart program:
import 'dart:io';
void main() {
print("Enter the first number : ");
int first = int.parse(stdin.readLineSync());
print("Enter the second number : ");
int second = int.parse(stdin.readLineSync());
print("Remainder of $first/$second ${first.remainder(second)}");
}
Sample Output:
It will give outputs as like below:
Enter the first number :
4
Enter the second number :
5
Remainder of 4/5 4
Enter the first number :
10
Enter the second number :
2
Remainder of 10/2 0
You might also like:
- Dart check for any or every element in a list satisfy a given condition
- Dart program to check if a list contains a specific element or not
- How to shuffle a dart list
- Encoding/decoding JSON in Dart explanation with examples
- Dart program to check if a year is leap year or not
- How to find the ceil and floor values of a number in Dart