Team LiB
Previous Section Next Section

Relational Operators

Relational operators include the following:

The following is an example of using relational operators.

Code Example: Relational Operators
Start example
using System;

namespace Client.Chapter_2___ Expressions_and_ Operators
{
      class RelationalOperators
      {
            static void Main(string[] args)
            {
                  int a, b;
                  a = 1;
                  b = 2;
                  if (a > b)
                    b = 10;
                  if (b < a)
                        a = 10;
                  if (a >= b)
                        b = 20;
                  if (b <= a)
                        a = 20;
                  if (a == b)
                        b = 5;
                  if (b != a)
                        b = a;
            }
      }
}
End example

Team LiB
Previous Section Next Section