Operators and Expressions in C

Gowri Mungath
2 min readMay 9, 2021

The symbols which are used to perform logical and mathematical operations in a C program are called C operators. These C operators join individual constants and variables to form expressions.

Output of the above program

In C, Zero is used to represent false, and One is used to represent true.

Types of C operators

  • Arithmetic Operators: used to perform mathematical calculations like addition subtraction, multiplication, division and modulus.
  • Increment/decrement operators: used to either increase/decrease the value of a variable by one. They are of two types → pre-increment/pre-decrement operator and post-increment/post-decrement operator. For pre-increment/decrement (++a), before assigning the value to the variable, the value is incremented/decremented by one. For post-increment/decrement (a++), after assigning the value to the variable, the value is incremented/decremented by one.
  • Assignment operator: used to assign the values for the variables in C programs.
  • Relational operators: used to compare the value of two variables.
  • Logical operators: used to perform logical operations on the given two variables.
  • Bitwise operators: used to perform bitwise operations on given two variables. The mathematical operations are converted into bit-level which makes processing faster. To learn more → https://youtu.be/jlQmeyce65Q
  • Conditional operators: return one value if condition is true else return another value. The general syntax : Test_expression ? statement 1 : statement 2 → Here, if the given Test_expression is true then it will return statement 1 and if the given Test_expression is false then it will return statement 2.

Operator precedence describes the order in which C reads expressions and associativity defines the order in which operators of the same precedence are evaluated in the expression. Associativity can be either from left to right or right to left.

--

--