compare variables in pascal

In Pascal, you can compare variables using various comparison operators. Here are some examples:

  • Equal: To check if two variables are equal, you can use the = operator. For example:

pascal var a, b: Integer; isEqual: Boolean; begin a := 5; b := 10; isEqual := a = b; // isEqual will be False end;

  • Not Equal: To check if two variables are not equal, you can use the <> operator. For example:

pascal var a, b: Integer; isNotEqual: Boolean; begin a := 5; b := 10; isNotEqual := a <> b; // isNotEqual will be True end;

  • Less Than: To check if a variable is less than another variable, you can use the < operator. For example:

pascal var a, b: Integer; isLessThan: Boolean; begin a := 5; b := 10; isLessThan := a < b; // isLessThan will be True end;

  • Greater Than: To check if a variable is greater than another variable, you can use the > operator. For example:

pascal var a, b: Integer; isGreaterThan: Boolean; begin a := 5; b := 10; isGreaterThan := a > b; // isGreaterThan will be False end;

  • Less Than or Equal To: To check if a variable is less than or equal to another variable, you can use the <= operator. For example:

pascal var a, b: Integer; isLessThanOrEqual: Boolean; begin a := 5; b := 10; isLessThanOrEqual := a <= b; // isLessThanOrEqual will be True end;

  • Greater Than or Equal To: To check if a variable is greater than or equal to another variable, you can use the >= operator. For example:

pascal var a, b: Integer; isGreaterThanOrEqual: Boolean; begin a := 5; b := 10; isGreaterThanOrEqual := a >= b; // isGreaterThanOrEqual will be False end;

These are the basic comparison operators in Pascal that you can use to compare variables.