What is an expression?
In any programming language, if we want to perform any calculation or to frame any condition etc., we use a set of symbols to perform the task. These set of symbols makes an expression.
In C programming language, an expression is defined as follows...
An expression is a collection of operators and operands that represents a specific value.
In the above definition, operator is a symbol which performs tasks like arithmetic operations, logical operations and conditional operations etc.,
Operands are the values on which the operators perform the task. Here operand can be a direct value or variable or address of memory location.
Expression Types in C
In C programming language, expressions are divided into THREE types. They are as follows...
- Infix Expression
- Postfix Expression
- Prefix Expression
The above classification is based on the operator position in the expression.
The expression in which operator is used between operands is called as infix expression.
The infix expression has the following general structure...
Operand1 Operator Operand2
The expression in which operator is used after operands is called as postfix expression.
The postfix expression has the following general structure...
Operand1 Operand2 Operator
The expression in which operator is used before operands is called as prefix expression.
The prefix expression has the following general structure...
Operator Operand1 Operand2