C EXPRESSIONS AND STATEMENTS – A BRIEF DESCRIPTION
C EXPRESSIONS –
Generally, C EXPRESSIONS are the combinations of operators, constants, variables and function calls. Operators, constants, and variables are the constituents of C Expressions. Furthermore, we can C EXPRESSIONS by the following definition..
“A C expression is any valid combination of the elements such as operators, constants, variables and function calls.”
Generally, most of the expressions tend to follow the general rules of algebra, we take them insincerely. However, there are a few aspects of expressions which relate specifically to C.
ORDER OF EVALUATION –
Generally, there’s no specification in C Language about the order in which we can evaluate the sub-expressions of C expressions. This certainly leaves the compiler free to rearrange an expression so as to produce more optimal code.
Furthermore, this also means that the code should never rely upon the order in which we evaluate the sub-expressions.
TYPES OF C EXPRESSIONS –
Generally, C EXPRESSIONS can be arithmetic, logical or relational.. There description are as follows,
ARITHMETIC EXPRESSIONS :
These are the expressions which we use for numeric calculations in a C program. These expressions include the C expressions conducting addition, subtraction, multiplication, division, etc.
Some of the valid examples of arithmetic expressions are as follows :
- x + y
- a – b
- m * n
- c / d
Now, some of the invalid examples of arithmetic expressions are as follows :
- + a b
Because the arithmetic operator “+” is before the operand “a” and not in between “a” and “b“. Therefore, making the Arithmetic expression invalid.
- x +* y
Because, in the expression there are 2 arithmetic operators between the operands “x” and “y“. Therefore, making the Arithmetic expression invalid.
- m n
Because, in the above expression there is no arithmetic operator between the operands “m” and “n“. Therefore, making the Arithmetic expression invalid.
- c * d -* e
Because, in the above expression multiple operators are there in between the operands. Such as, “*” in between “c” and “d” and “–” and “*” in between “d” and “e“. Therefore, making the Arithmetic expression invalid.