How to find the Maximum of Three Numbers in Dart - Step by Step Examples
How to find the Maximum of Three Numbers in Dart ?
Answer
To find the maximum of three numbers in Dart, you can use the `max` function from the dart:math library.
✐ Examples
1 Find Maximum of Three Numbers
In this example,
- We import the dart:math library to use the `max` function.
- We declare three variables
a
,b
, andc
with the numbers to compare. - We use the `max` function to compare the numbers and get the maximum.
Dart Program
import 'dart:math';
void main() {
int a = 5;
int b = 8;
int c = 3;
int max = max(a, max(b, c));
print('Maximum of three numbers is: $max');
}
Output
Maximum of three numbers is: 8
Summary
In this tutorial, we learned How to find the Maximum of Three Numbers in Dart language with well detailed examples.