You are on page 1of 6

R.

Srinivasan
(Assistant Professor)
Phone: 9952218180
E-mail: srinivar@srmist.edu.in
Affiliation: Department of Computer Science and
Engineering
Expression
Expression evaluation is mainly depending on priority and associativity. An expression is
a sequence of operands and operators that reduces to a single value.
An expression is a combination of variables constants and operators written according to
the syntax of C language. Every expression result in some value of a certain type that can
be assigned to a variable.
Priority This represents the evaluation of expression starts from "what" operator.
Associativity It represents which operator should be evaluated first if an expression is
containing more than one operator with same priority.
Expression: Evaluating the expression
Pre-increment and Post-increment Expression

C programming has two operators increment ++ and decrement -- to change the value of
an operand (constant or variable) by 1. Increment ++ increases the value by 1 whereas
decrement -- decreases the value by 1. These two operators are unary operators, meaning
they only operate on a single operand.

#include <stdio.h>
int main() Output:
{
int a = 10, b = 100; ++a = 11
float c = 10.5, d = 100.5; --b = 99
printf("++a = %d \n", ++a); ++c = 11.500000
printf("--b = %d \n", --b); ++d = 99.500000
printf("++c = %f \n", ++c);
printf("--d = %f \n", --d);
return 0;
}
Expression with conditional and assignment operator

The following expression determines which variable has the greater value, y or z, and
assigns the greater value to the variable x:
x = (y > z)? y:z;
The following statement is equivalent to the previous expression.
if (y > z)
x = y;
else
x = z;

You might also like