## Relational Operators Relational operator are crucial for making decisions. They permit us to compare numeric and also char (chars space treated prefer numbers in C++) worths to recognize if one is higher than, much less than, same to, or no equal come another.

You are watching: When a relational expression is false, it has the value ________.

Relational operators room binary an interpretation they need two operands.

Relational operators have actually left to appropriate associativity. Left to right associativity means that once two operator of same precedence space adjacent, the left many operator is evaluate first.

Relational Operators definition
> Greater than
= Greater 보다 or same to

## Relational Expression Examples

x > y

x == y

Note: It have the right to be straightforward to forget the equal to is “==” and also not “=” i beg your pardon is assignment. In many cases, the compiler won’t keep in mind this together an error since x==y and x=y are both precious expressions.

### What is the an outcome of a relational expression?

Relational expressions are Boolean expressions and thus are equal to one of two people true or false.

5 > 4
true
5 == 5
true
1
true
5 != 5
false
1 > 3
false
1 >= 1
true

### How a program treats true and false

C++ programs keep true and also false in memory as numbers.

false is stored together 0

true is stored together 1

### Relational operator precedence and also relationship come the various other operators

Note how the relational operator rank in precedence come the mathematical and assignment operators. Also, keep in mind that the less than/greater than operators have higher precedence 보다 the equal/not equal relational operators.

Precedence highest to lowest
( )
*, /, %
+, -
>, >=, bool data kind variable. As provided in the example, programmers often enclose relational expressions in clip to enhance readability.

int x = 5;int y = 10;bool result;// Assign an outcome of relational expression come bool form variableresult = x > y; // result is falsecout y: " y / 5; // result is true// equivalent, parentheses space not needed however adds readability hereresult = (x + 10) > (y / 5); // bool variable is calculation as 0 or 1 instead of true or falsecout (y / 5): " ## Comparing characters with relational operators

As disputed earlier, characters are stored in memory as integers. Thus, you deserve to compare personalities using relational expressions as with they to be numbers.

char testCharacter = "c";if (testCharacter == "c") cout The > and ‘a’ is false.

See more: Flights From Atl To Pbi - Atl To Pbi (Atlanta To West Palm Beach) Flights

## Comparing strings with relational operators

You can additionally compare strings using relational operators. As soon as a relational operator is provided with strings, the integer value of every character that the left operand is compared to the integer worth of every character that the ideal operand working from left to right.

“tim” == “tom” // false due to the fact that the 2nd characters i and o do not match

“Tim” == “tim” // false because T and also t carry out not match

“abc”

## Character testing functions

Character duty Description
isalpha true if letter in alphabet
isdigit true if number from 0-9
isalnum true if letter in alphabet or numerical digit
islower true if lowercase letter
isprint true if printable character including space
ispunct true if printable character other than digit, letter, or space
isupper true if uppercase letter
isspace true if character is whitespace (tab, vertical tab, space, or newline

All of these attributes have a single character parameter for this reason you deserve to use them like this