Operator and Expression in c programming language
Learn about Operators and Expressions in C Programming Language
In C programming language, an operator is a symbol that represents an action or operation to be performed on one or more operands. An expression, on the other hand, is a combination of operators, variables, and literals that can be evaluated to produce a value.
C programming language supports various types of operators, such as arithmetic, relational, logical, bitwise, assignment, and conditional operators. Some examples of these operators are:
Operator are categorized in 3 ways
Unary operator
|
binary operator |
Tenery operator |
Depending upon operation operator categories are
- Arithmetic Operator
- Assignment operator
- Relational operator
- Logical Operator
- Bitwise operator
- sizeof operator
- increment and decrement Operator
- shift operator
- conditional operator
- reference operator
- dereference operator
- compound assignment operator
- comma operator( , )
- dot operator( . )
- arrow operator( -> )
- index operator( [ ] )
- grouping operator ( )
Command for see the operator list on Linux environment
Before jumping the operator we can see some Examples and rules
Example 01: c=a+b
conclusion: + will do first because of the associativity and priority after that after the assignment operator will perform
Note: Whenever you are solving operator we have to encounter priority and associativity
Example 02: c=a+b*2
conclusion: first perform the highest priority operator here higher priority operator is multiplication after the second highest priority operator addition will perform at last lowest priority operator will perform. if whenever same priority operator will come at the same time then Associtivity comes into the picture.
Example 03: c=a/b*2
conclusion: here / and * both are the same priority then associativity will low left to right, the division first, multiplication second, assignment last will perform.
list of associativity and priority operator
Example 04 : C = A+B -
D*E
/ F
when a constant and different variable in between same operator is there, then they all are converted into the same operator. the compiler will convert all operands upto the type of the biggest operand