Types of Operators in C Programming
Arithmetic Operators (five) |
+ - Addition / unary plus - - Subraction / unary minus * - Mulitplication / - Division % - Modulo division
e.g. -14%3 = -2 14%-3 = 2 |
||||||||||||
Relational Operators (six) |
< is less than (is complement of >=) <= is less than or equal to > is greater than (is complement of <=) >= is greater than or equal to == is equal to (is complement of !=) != is not equal to |
||||||||||||
Logical Operators |
&& - AND || - OR ! – NOT Combines two or more relational expressions, is termed as a logical expression |
||||||||||||
Assignment Operators |
var = var op (exp) è var op= var (var – variable, op – operator, exp – expression) e.g.
|
||||||||||||
Increment and Decrement Operators |
++ (Increment) -- (Decrement)
e.g. ++a, a++ --b, b--
|
||||||||||||
Conditional Operator |
Ternary operator pair “?:” exp1 ? exp2 : exp3 exp1 is evaluated first, if non zero(true), then exp2 is evaluated, exp1 is false, then exp3 is evaluated.
|
||||||||||||
Bitwise Operator |
Used to manipulate the data at bit level. & - bitwise AND | - bitwise OR ^ - bitwise exclusive OR >> - shift right
|
||||||||||||
Special Operators |
Comma (,) operator, sizeof operator, pointer operators (& and *), member selection operator (. and ->) Comma Operator:
e.g. in for loops size of Operator:
e.g. m = sizeof(sum); n = sizeof(long int); k = sizeof(255L); |