codeGK
Code it ALL
C++ Operators - CodeGK
♦ C++ Operators

♣ About C++ Operators

Operators in C++ are fundamentally used to perform operations on Variables and Values.
Various types of Operators exist in C++.
  • Comparison Operators
  • Arithmetic Operators
  • Assignment Operators
  • Logical Operators
  • Identity Operators
  • Membership Operators
  • Bitwise Operators

♣ Example1: Comparison Operators in C++

Comparison operator perform comparison between two variable at base level and output a boolean(true/false) value.
Below is the list of comparison operators.
  • Greater Than: a > b
  • Greater Than or Equal to: a >= b
  • Less Than: a < b
  • Less Than or Equal to: a <= b
  • Equal to: a == b
  • Not Equal to: a != b
In this example, Comparison operators are illustrated.
Example
Input:
Output:

♣ Example2: Arithematic Operators in C++

Arithmetic Operations in Python are used to perform Mathematical Operations.
Table Info
OperatorWorking
+Addition
-Subtraction
*Multiplication
/Division
%Modulo
++Increment
--Decrement
In this example, Arithmetic Operations are illustrated.
Example
Input:
Output:

♣ Example3: Assignment Operators in C++

Assignment Operations in Python are used for assignment of (values)/(variable values) to variables.
Table Info
OperatorWorking
=Data Assignment
+=Addition Increment
-=Subtraction Decrement
*=Multiplication Increment
/=Division Decrement
%=Modulo Assignment
In this example, Assignment Operations are illustrated.
Example
Input:
Output:

♣ Example4: Logical Operators in C++

Logical Operators in C++ are used to evaluate conditional statements and produce Boolean output.
Table Info
OperatorWorking
&&returns True if all variables/statements are True
||returns True if atleast one variables/statements are True
~returns the reverse of Boolean value
In this example, Logical Operators are illustrated.
Example
Input:
Output:
Prev_LessonNext_Lesson