Operators in C++ by 124study.blogspot.in
Types of operators
- Assignment Operator
- Mathematical Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Shift Operators
- Unary Operators
- Ternary Operator
- Comma Operator
Assignment Operator ( = )
Mathematical Operators
int x=10; x += 4 // will add 4 to 10, and hence assign 14 to X. x -= 5 // will subtract 5 from 10 and assign 5 to x.
Relational Operators
int x = 10; //assignment operator x=5; // again assignment operator if(x == 5) // here we have used equivalent relational operator, for comparison { cout <<"Successfully compared"; }
Logical Operators
Bitwise Operators
- Bitwise AND operators
&
- Bitwise OR operator
|
- And bitwise XOR operator
^
- And, bitwise NOT operator
~
Shift Operators
Unary Operators
Ternary Operator
int a = 10; a > 5 ? cout << "true" : cout << "false"
Comma Operator
int a,b,c; // variables declaration using comma operatora=b++, c++; // a = c++ will be done.
0 comments:
Post a Comment