C++ relational operators

Created By: chatGPT

C++ provides several relational operators that are used to compare values, which include: ==, !=, >, <, >=, and <=. These operators return a boolean valuetrue or false depending on the comparison. Here’s a breakdown of each operator:
== checks if two values are equal.
if (a == b) {
    // true if a is equal to b
}
!= checks if two values are not equal.
if (a != b) {
    // true if a is not equal to b
}
> checks if the left value is greater than the right value.
if (a > b) {
    // true if a is greater than b
}
< checks if the left value is less than the right value.
if (a < b) {
    // true if a is less than b
}
>= checks if the left value is greater than or equal to the right value.
if (a >= b) {
    // true if a is greater than or equal to b
}
<= checks if the left value is less than or equal to the right value.
if (a <= b) {
    // true if a is less than or equal to b
}
Example of using relational operators in a program: Below is a simple program that demonstrates the use of these operators.
#include <iostream>

int main() {
    int a = 10;
    int b = 20;

    std::cout << "a == b: " << (a == b) << std::endl;
    std::cout << "a != b: " << (a != b) << std::endl;
    std::cout << "a > b: " << (a > b) << std::endl;
    std::cout << "a < b: " << (a < b) << std::endl;
    std::cout << "a >= b: " << (a >= b) << std::endl;
    std::cout << "a <= b: " << (a <= b) << std::endl;
    return 0;
}
Introduction And SetupVariablesData TypesIntFloatDoubleCharBoolStringVoidConstantsOperatorsArithmetic OperatorsRelational OperatorsLogical OperatorsBitwise OperatorsAssignment OperatorsTernary OperatorControl FlowIf StatementElse StatementElse If StatementSwitch StatementFor LoopWhile LoopDo While LoopBreak StatementContinue StatementGoto StatementFunctionsFunction DeclarationFunction DefinitionFunction OverloadingInline FunctionsDefault ArgumentsRecursionPass By ValuePass By ReferenceData StructuresArraysMultidimensional ArraysStructsEnumsUnionsClassesObjectsMember FunctionsConstructorsDestructorsAccess SpecifiersPublicPrivateProtectedInheritancePolymorphismFunction OverridingVirtual FunctionsPure Virtual FunctionsOperator OverloadingTemplatesNamespaceCommentsSingle Line CommentsMulti Line CommentsSyntaxSemicolonCurly BracesParenthesesEvent HandlingCinCoutError HandlingTry BlockCatch BlockThrow StatementException HandlingPreprocessor DirectivesInclude GuardsMacro DefinitionsInline AssemblyStatic KeywordsExtern KeywordsConst KeywordsVolatile KeywordsFriend FunctionStatic MemberThis PointerDynamic Memory AllocationNew OperatorDelete Operator