Expressions in C
Expressions are meaningful combinations of constants, variables and function calls. Most expressions have both a value and a type. The expression may consist of a single entity, such as a constant or variable, or it may consist of some combination of such entities, interconnected by one or more operators. Expressions can also represent logical conditions which are either true or false.
Several simple expressions are given below:
a + b
This expression represents the sum of the values assigned to variables a and b.
x = y
This expression causes the value represented by y to be assigned to x.
t = u + v
In this expression, the value of the expression (u + v) is assigned to t. It is poor programming practice to mix data types in assignment expressions. Thus, the data types of the constants or variables on either side of the = sign should always match
An expression statement consists of an expression followed by a semicolon.
area = PI * radius * radius; – This causes the value of the expression on the right of the equal sign to be assigned to the variable on the left.
Support us by sharing this post