C++
OPERATORS
AN IN-DEPTH GUIDE WITH DIAGRAMS AND EXAMPLES
INTRODUCTION
• Operators in C++ are symbols that perform operations on
variables and values.
• Types of operators include:
• - Arithmetic Operators
• - Relational Operators
• - Logical Operators
• - Bitwise Operators
• - Assignment Operators
• - Miscellaneous Operators
ARITHMETIC OPERATORS
• Used to perform mathematical operations.
• Examples:
• + (Addition)
• - (Subtraction)
• * (Multiplication)
• / (Division)
• % (Modulus)
• Example Code:
• int a = 10, b = 5;
• cout << (a + b); // Output: 15
RELATIONAL OPERATORS
• Used to compare values.
• Examples:
• == (Equal to)
• != (Not equal to)
• > (Greater than)
• < (Less than)
• >= (Greater or equal)
• <= (Less or equal)
• Example Code:
• int x = 5, y = 10;
• if (x < y) {
• cout << 'X is smaller';
• }
LOGICAL OPERATORS
• Used to perform logical operations.
• Examples:
• && (Logical AND)
• || (Logical OR)
• ! (Logical NOT)
• Example Code:
• bool a = true, b = false;
• if (a && b) {
• cout << 'Both True';
• } else {
• cout << 'False';
• }
FLOWCHART: ARITHMETIC
OPERATIONS
• A simple flowchart for arithmetic operations.
• (Flowchart to be added manually in PowerPoint)
CONCLUSION
• C++ Operators are fundamental to performing
operations in programming.
• Understanding them helps in writing efficient
code.
• Practice using different operators in real-world
scenarios!