Expression Basics : What is Expression in C Programming ?



A. Expression :

  1. In programming, an expression is any legal combination of symbols that represents a value. [Definition from Webopedia]
  2. C Programming Provides its own rules of Expression, whether it is legal expression or illegal expression. For example, in the C language x+5 is a legal expression.
  3. Every expression consists of at least one operand and can have one or more operators.
  4. Operands are values and Operators are symbols that represent particular actions.

B. Valid Expressions :

C Programming is compiler by compiler, In the different phases of compiler Expression is checked for its validity.

ExpressionsValidity
a + bExpression is valid since it contain + operator which is binary operator
+ + a + bInvalid Expression

C. Priority and Expression :

In order to solve any expression we should have knowledge of C Programming Operators and their priorities.

D. Types of Expression :

In Programming, different verities of expressions are given to the compiler. Expressions can be classified on the basis of Position of Operators in an expression -

TypeExplanationExample
InfixExpression in which Operator is in between Operandsa + b
PrefixExpression in which Operator is written before Operands+ a b
PostfixExpression in which Operator is written after Operandsa b +
These expressions are solved using the stack.