The relational operators are as follows:
Operator
Meaning
==
Equal to
!=
Not equal to
>
Greater than
Less than
>=
Greater than or equal to
Less than or equal to
using System;
class MainClass
{
static void Main(string[] args)
{
int a = 10, b = 20, c = 30;
if (a < 15 && b < 20)
c = 10;
Console.WriteLine(c);
if (a < 15 || b < 20)
c = 15;
Console.WriteLine(c);
if (!(a == 15))
c = 25;
Console.WriteLine(c);
}
}
using System;
class MainClass
{
static void Main(string[] args)
{
int a, b;
a = 1;
b = 2;
if (a > b)
b = 10;
Console.WriteLine(b);
if (b < a)
a = 10;
Console.WriteLine(a);
if (a >= b)
b = 20;
Console.WriteLine(b);
if (b <= a)
a = 20;
Console.WriteLine(a);
if (a == b)
b = 5;
Console.WriteLine(b);
if (b != a)
b = a;
Console.WriteLine(b);
}
}
using System;
class Example {
public static void Main() {
int i, j;
i = 10;
j = 11;
if(i < j)
Console.WriteLine("i < j");
if(i <= j)
Console.WriteLine("i <= j");
if(i != j)
Console.WriteLine("i != j");
if(i == j)
Console.WriteLine("this won't execute");
if(i >= j)
Console.WriteLine("this won't execute");
if(i > j)
Console.WriteLine("this won't execute");
}
}
i