C Programming Expression

A. C Programming 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.

Valid C Programming Expression :

C Programming code gets compiled firstly before execution. In the different phases of compiler, c programming 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

Priority and Expression :

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

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 +

These expressions are solved using the stack.

Examples of Expression :

Now we will be looking into some of the C Programming Expressions, Expression can be created by combining the operators and operands

Each of the expression results into the some resultant output value. Consider few expressions in below table

Expression Examples,Explanation
n1 + n2,This is an expression which is going to add two numbers and we can assign the result of addition to another variable.
x = y,This is an expression which assigns the value of right hand side operand to left side variable
v = u + a * t,We are multiplying two numbers and result is added to ‘u’ and total result is assigned to v
x <= y,This expression will return Boolean value because comparison operator will give us output either true or false ++j,This is expression having pre increment operator\, it is used to increment the value of j before using it in expression [/table]