Operators
The different types of operators in C and C++ Programming are :
- Unary Operators (C and C++) – An Operator which acts on only one operand is called unary operator. The priority is maximum of this operator.
5. Sizeof()
++ increases a value of variable by 1.
Example: a++ or ++a (Post and Pre increment)
— decreases a value of variable by 1.
Example: b– or – –b (Post and Pre decrement)
Detailed Explanation in YouTube – (Like, Subscribe, Share)
https://youtu.be/4EfuHyhqp9w?si=5J2OO2qcCTUjn-5u
- Arithmetic Operators (C and C++) – Used to perform basic mathematical operations.
Detailed Explanation in YouTube – (Like, Subscribe, Share)
https://youtu.be/4EfuHyhqp9w?si=5J2OO2qcCTUjn-5u
- Bitwise Operators (C and C++) — Work at the bit (binary) level.
Detailed Explanation in YouTube – (Like, Subscribe, Share)
https://youtu.be/4EfuHyhqp9w?si=5J2OO2qcCTUjn-5u
- Relational (Comparison) Operators (C and C++) — Used to compare two values. They return true (1) or false (0).
Detailed Explanation in YouTube – (Like, Subscribe, Share)
https://youtu.be/4EfuHyhqp9w?si=5J2OO2qcCTUjn-5u
- Logical Operators (C and C++) — Used to combine conditions.
- Detailed Explanation in YouTube – (Like, Subscribe, Share)
- https://youtu.be/4EfuHyhqp9w?si=5J2OO2qcCTUjn-5u
- Assignment Operators (C and C++) — Used to assign values to variables.
- Conditional (Ternary) Operator (C and C++) — Short form of (if-else).
- Address & Pointer operators (C and C++)
- & — address of variable
- * — value at address (pointer reference)
Example:
int x = 10;
int *p = &x;
- Scope Resolution Operator (:: ) (C++)
- Used to access:
- * global variables
- * namespace members
- * class members outside class
Example:
cpp
std::cout << “Hello”;
They are essential tools to control your program efficiently.
Summary
In C, operators help you:
* Perform math
* Compare values
* Combine conditions
* Work with memory and bits
* Assign or update data
Operators in C++ help perform:
* Math
* Comparison
* Logic
* Bit manipulation
* Memory pointer use
* Object and class access
* Namespace access
Operators allow your program to calculate, compare, decide, and manage data easily.
