We learn what is operator and its features. In this lession we learn Expression in C
Collection of one or more operators and one or more variables(operand) is nothing but expression in c. Ex: a+b or a+10.
Arithmetic Expressions
An arithmetic expression is a combination of variables,constants, and operators arranged as per the syntax of the language.C can handle any complex mathematical expressions.some of the examples are listed below.
Evaluation Expressions
Expressions are evaluated using an assignment statement of the form.
Ex: variable= expression
| Algebraic Expression | C Expression |
|---|---|
| a X b-c | a*b-c |
| (m+n)(a+b) | (m+n)*(a+b) |
Variable is any valid C variable name.
Examples of Evaluated Expressions are
x=a*b-c;
y=b/c*a;
c=a-b/x+y;
Rules for Evaluation of Expressions
- First parenthesized sub expression from left to right are evaluated.
- If parentheses are nested,the evaluation begins with the innermost sub-expression.
when parentheses are used, the expressions within parentheses assume highest priority.
Precedence of Arithmetic Operators
An arithmetic expression without parentheses will be evaluated from left to right using the rules of precedence of operators. The following are the rules
High priority */%
Low priority +-.
Example program on expressions
#include<stdio.h>
d=24 d=112

No comments:
Post a Comment