Sunday, July 7, 2013

Expressions in C

Expressions are nothing but everything we represent. An expression can be a constant or a variable. The operations performed on these expressions are also considered to be as expressions. Based on the complexity of the expressions, they are divided into two types.

  1. Simple Expressions
  2. Complex Expressions
Expressions plays an important role in building logic to a C program. To perform some operation in C, we need to use these Expressions.

Simple Expressions:

Simple Expressions are nothing but single existence of the expressions.
For example,
Literal Constant - 5
Symbolic Constant - PI 
Variables - x
All the above values are expressions. A literal constant has a fixed value i.e., its own value. A Symbolic Constant is assigned a value at the beginning of the program and can't be changed. A variable is having a value and it may change from time to time.

All the above expressions are considered to be simple, as they doesn't have much calculations.

Complex Expressions: 

Complex Expressions are the combinations of simple expressions.
For example, 
2+3
is a complex expressions, it consists of two literal constants performing an Arithmetic operation. We can also perform this kind of operations on variables and they are also considered to be Complex Expressions.

For example,
x+y
is a complex expression with variables x and y and an operation of summing up on them.

We can have still complex expressions like
(x+(y*8))+z 
is also a complex expression in which the solving of the above expressions considers the priority of the operators which we will discuss in the later sections.

What happens if a printf() is present inside a printf()??? To know click here.