Operator and Expression in c programming language

23 Jul 2022 Balmiki Mandal 0 C Programming

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

 1 operand

binary operator

  2 operand

Tenery operator

   3 operand

 

Depending upon operation operator categories are

  1. Arithmetic Operator
  2. Assignment operator
  3. Relational operator
  4. Logical Operator
  5. Bitwise operator
  6. sizeof operator
  7. increment and decrement Operator
  8. shift operator
  9. conditional operator
  10. reference operator
  11. dereference operator
  12. compound assignment operator
  13. comma operator( , )
  14. dot operator( . )
  15. arrow operator( -> )
  16. index operator( [ ] )
  17. grouping operator ( )

 

Command for see the operator list on Linux environment

$man operator    (manual list of all operators)
$man ASCII        (ASCII list)

 

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 

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.