Structure: Comparison Operators Flashcards

1
Q

Comparison operators used in conjunction with if. Meaning equal to, not equal to, less than, and greater than.

A

==, !=, <, >

Example

if (someVariable \> 50)
{
// do something here
}

This tests to see if someVariable is greater than 50 and if it is than an action will be performed. Otherwise the lines will be skipped over.

Comparison Operators

x == y (x is equal to y)
x != y (x is not equal to y)
x < y (x is less than y)
x > y (x is greater than y)
x <= y (x is less than or equal to y)
x >= y (x is greater than or equal to y)

Note the single “=” is the assignment operator not the equal sign

How well did you know this?
1
Not at all
2
3
4
5
Perfectly