Expression Basics : What is Expression in C Programming ?
A. Expression :
- In programming, an expression is any legal combination of symbols that represents a value. [Definition from Webopedia]
- 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.
- Every expression consists of at least one operand and can have one or more operators.
- 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.
Expressions | Validity |
---|---|
a + b | Expression is valid since it contain + operator which is binary operator |
+ + a + b | Invalid 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 -
Type | Explanation | Example |
---|---|---|
Infix | Expression in which Operator is in between Operands | a + b |
Prefix | Expression in which Operator is written before Operands | + a b |
Postfix | Expression in which Operator is written after Operands | a b + |