The relational operators in C++ include six types: >, <, >=, <=, !=, and ==. As the name suggests, relational operators require two operands to be compared, such as who is bigger and who is smaller. Who is equal but not equal... So in this case, the result of the relational operator expression is either 0 or 1. Please understand this sentence.
Below we use examples to help you understand these six operators, such as:
10>5;//10 is greater than 5, it is obviously true, it is true 2>=2;//2 is greater than or equal to 2, it is also true, it is true 3!=1;//3 is not equal to 1, it is indeed true, it is True 5==5; //5 is indeed equal to 5, established, true
Please understand the usage of the above four expressions, and then try to print their values using code.
Reference code:
#include<iostream>usingnamespacestd;intmain(){cout<<(10>5)<<endl;cout<<(2>=2)<<endl;cout<<(3!=1)<<endl;cout <<(5==5)<<endl;return0;}
Please experiment on your own and try to modify and use other operators.