Expressions and its uses in #C program (module 11)

In this section we will discuss on the different expressions in C and there uses in functions and in any C program

This is the 11th module on learning C with us. Earlier we discussed on the basic introduction and structure of C, preprocessor it's features, intermediate and executable codes. compilation and execution process of a C program. And keywords and identifiers, data types, variables and constants, scope of variables, operators in C.

In this section we will discuss on the different expressions in C and there uses in functions and in any C program.

Expressions in #C :-

An expression is a sequence of operators and operands that reduces to a single value. Expressions can be simple or complex. A operator is a syntactical token that requires an action be taken. An operand is an object on which an operation is performed.

A simple expression contains only one operator. Eg. 2+3 is a simple expression whose value is 5.

Arithmetic expressions is a combinations of variables, constants, & operators arranged according to the syntax of C language.

Some example :

A*B-C

(M+N)*(X+Y)

Expressions are evaluated using an assignment statement of the form

Variable = expression

The precedence or priorities of operator are as follows:

High * , / , %

Low + , -

An expression is evaluated in left to right & value is assigned to variable in left side of assignment operators.

int main()

{ float a=9,b=23,c=3,x,y,z;

x = a-b/3+c*2-1;

y = a-b/(3+c)*(2-1);

z = a-(b/(3+c)*2)-1;

printf("valurs of x y z are %d %d %d"x,y,z);

}

In next module we will continue on the next module on type of conversion in C i.e module 12. For more information please be updated with us as we provide all the modules and cover all the topics regarding #C. Only on Www.newsandstory.com