C++ examples for Operator:Relational Operator
Operator | Meaning |
---|---|
< | less than |
<= | less than or equal to |
> | greater than |
>= | greater than or equal to |
== | equal to |
!= | not equal to |
Comparing data values
#include <iostream> int main()/* w w w .ja v a 2 s .c om*/ { char first {}; char second {}; std::cout << "Enter a character: "; std::cin >> first; std::cout << "Enter a second character: "; std::cin >> second; std::cout << "The value of the expression " << first << '<' << second << " is: " << (first < second) << std::endl; std::cout << "The value of the expression " << first << "==" << second << " is: " << (first == second) << std::endl; }