Professional Documents
Culture Documents
Relational Operators: Joaquin, J. Sanchez, T
Relational Operators: Joaquin, J. Sanchez, T
2
Relational
Operators
Joaquin, J.
Sanchez, T.
Slides by GDCuyasen
Target
• Analyze relational operators.
• Explore how to form and evaluate logical(Boolean)
expression.
Operators
• Arithmetic
• Relational
• Logical
Relational Operators
Examples,
A * B B - 10
A > B U == P
Six Relational Operators
A < B
Yes = True
No = False
Reading Relational Expressions
grade == 1.00
All relational operators have equal priority and are lower than arithmetic
operators.
Boolean Expressions
• bool
• Stores Boolean values
Boolean Type
“Hello” == “hello”
False
The first character ‘H’ is less than the first character ‘h’ of
“hello” because the ASCII value of ‘H’ is 72 while ‘h’ is 104.
therefore, “Hello” is not equal to “hello”.
Equal with strings
False
“Bill” has four characters while “Billy” has five. Therefore, “Bill”
is the shorter string. All four characters of “Bill” are the same as
the corresponding first four characters of “Billy”, and “Billy” is
the larger string. Therefore, “Bill” >= “Billy” is False.
References
• Malik, D. (2011). C++ Programming (5th ed., pp. 6-9). Boston, MA: Course Technology.
• Deitel, H., & Deitel, P. (2005). C++ How to Program. Upper Saddle River, N.J.: Pearson
Education.
• Wanna-Joke. Programmers problem. Retrieved from https://wanna-
joke.com/programmers-problems-4/
• GeeksforGeeks. Operators in C | Set 2 (Relational and Logical Operators) Retrieved from
https://www.geeksforgeeks.org/operators-in-c-set-2-relational-and-logical-operators/
• Rebus Community. Programming Fundamentals. Retrieved from
https://press.rebus.community/programmingfundamentals/chapter/relational-operators/