Relational Operators Example Program in Dart


This Dart code is demonstrating how to use comparison operators to compare two variables. Here's what's happening in this code:

  • int a, b; : This line declares two integer variables a and b.
  • a = 123; : This line assigns the value 123 to the variable a.
  • b = 10; : This line assigns the value 10 to the variable b.
  • print("Greater than : ${a > b}");: This line uses the > operator to compare a and b and prints the result to the console using string interpolation.
  • print("Lesser than : ${a < b}");: This line uses the < operator to compare a and b and prints the result to the console using string interpolation.
  • print("Greater than or equal to : ${a >= b}");: This line uses the >= operator to compare a and b and prints the result to the console using string interpolation.
  • print("Lesser than or equal to : ${a <= b}");: This line uses the <= operator to compare a and b and prints the result to the console using string interpolation.
  • print("Equality : ${a == b}");: This line uses the == operator to compare a and b and prints the result to the console using string interpolation.
  • print("Not equal : ${a != b}");: This line uses the != operator to compare a and b and prints the result to the console using string interpolation.

Source Code

void main(){
   int a,b;
   a=123;
   b=10;
   print("Greater than : ${a>b}");
   print("Lesser than : ${a<b}");
   print("Greater than or equal to : ${a>=b}");
   print("Lesser than or equal to : ${a<=b}");
   print("Equality : ${a==b}");
   print("Not equal	 : ${a!=b}");
}
To download raw file Click Here

Output

Greater than : true
Lesser than : false
Greater than or equal to : true
Lesser than or equal to : false
Equality : false
Not equal    : true