Professional Documents
Culture Documents
decrement operators
(operator hubungan, mantik dan peningkatan dan penurunan)
MARLINA MOHAMAD
BBP 15103
(COMPUTER PROGRAMMING)
WEEK 6.1
Learning outcomes
Example:
If i=10, j=3, so the logical value is true
If i=2, j=5, so the logical value is false
Relational operators
Example
Relational operators
Example 1
int quantity = 0;
cin >> quantity;
if ( quantity > 0 && quantity < 50)
Example 2
int umur = 0;
cin >> umur;
if ( age == 21 || age > 55 )
Example 3
int quantity = 0;
double price = 0.0;
cin >> quantity;
cin >> price;
if ( quantity < 100 && price < 10.35 )
Example 4
int quantity = 0;
double price = 0.0;
cin >> quantity;
cin >> price;
if ( quantity > 0 && quantity <100 || price >34.55)
Example Or ( || )
Order or precedence
The example :
Increment and Decrement operator
The example:
Increment and Decrement operator
Review questions
True or false?
Suppose x =5. After the statement y=x++; executes,
y is 5 and x is 6.
Answer: True
Answer : !=
Summary
Logical operators