Slide6Using Relational OperatorsRelational operators areused to compare two valuesMathC++PlainEnglishequals [example: if(a==b) [(a=b)meansputthevalueof b intoa]lessthanlessthanorequaltogreaterthangreater than or equal tonotequal to主二
Slide 6 Using Relational Operators Relational operators are used to compare two values Math C++ Plain English = == equals [example: if(a==b) ] [ (a=b) means put the value of b into a ] < < less than <= less than or equal to > > greater than >= greater than or equal to != not equal to
Slide7Examples:number0fstudents<20010>2020*j==10+i
Slide 7 Examples: numberOfStudents < 200 10 > 20 20 * j == 10 + i
Slide8Using Boolean (logical)operatorsBooleanoperators canbe usedtoformmorecomplexconditional expressions&&LogicalAND operatorI→LogicalOR operator>LogicalNOT operatorExamples:(x>5)&&(x<10)(x>10) I (x<5)!(x>5)Warning!&and/arealsooperators
Slide 8 Using Boolean (logical) operators Logical AND operator → && Logical OR operator → || Logical NOT operator → ! Examples: (x>5) && (x<10) (x>10) || (x<5) !(x>5) Warning! & and | are also operators Boolean operators can be used to form more complex conditional expressions