You are on page 1of 7

Chapter 1,2,3…

By Er. Rupesh Kumar Nidhi 1


Hierarchy of operations
The priority or precedence in which the operations in an arithmetic statement are performed is
called the hierarchy of operations.

Note that 6 / 4 gives 1 and not 1.5


because 6 and 4 both are integers and
therefore 6 / 4 must evaluate to an
integer. Similarly 5 / 8 evaluates to zero,
since 5 and 8 are integers and hence 5 / 8
must return an integer value.

By Er. Rupesh Kumar Nidhi 2


Associativity of Operators
Ø When an expression contains two operators of equal priority the tie
between them is settled using the associativity of the operators.
Ø All operators in C have either Left to Right associativity or Right to Left
associativity.
Ø Let us understand this with the help of a few examples.
vConsider the expression a = 3 / 2 * 5 ; Here there is a tie
between operators of same priority, that is between / and *. This tie
is settled using the associativity of / and *. Both enjoy Left to Right
associativity. Therefore firstly / operation is done followed by *.
vConsider a = b = 3 ; Here both assignment operators have the
same priority. So order of operations is decided using associativity
of = operator. = associates from Right to Left. Therefore, second = is
performed earlier than first =.

By Er. Rupesh Kumar Nidhi 3


Associativity of Operators…

By Er. Rupesh Kumar Nidhi 4


History of C

By Er. Rupesh Kumar Nidhi 5


Overview of C program

By Er. Rupesh Kumar Nidhi 6


Compiling and Running a program
Ø Compiler translates source program
into another representation or file
with extension .o called object
file.(e.g. sample.o)

Ø Linking is the process of putting


together other program files and
functions that are required by the
program

Ø And finally the compiled and linked


program is called executable object
code and stored as extension of .out
(e.g. sample.out)

By Er. Rupesh Kumar Nidhi 7

You might also like