Professional Documents
Culture Documents
Presented by: C8
37 – Sanket Bhosle
38 – Anurag Bhujbal
39 – Prathamesh Bhujbal
40 – Kshitij Bhure
41 – Dhananjay Bile
42 – Ayush Billade
Operators precedence and
associativity
Operator Precedence Operator Associativity
2
Table
Category Operator Associativity
Postfix () [] -> . ++ - - Left to right
Unary + - ! ~ ++ - - (type)* & sizeof Right to left
Multiplicative */% Left to right
Additive +- Left to right
Shift << >> Left to right
Relational < <= > >= Left to right
Equality == != Left to right
Bitwise AND & Left to right
Bitwise XOR ^ Left to right
3
Bitwise OR | Left to right
4
PRECEDENCE
Used to decide which operator will be evaluated first.
5*4-6 Precedence of
multiplication is
greater than addition.
(5 * 4) – 6 = 14 5 * (4 – 6) = -10
5
Associativity
Comes into picture when precedence of operators are same.
Associativity can be
10 / 2 * 5
either:
1) Left to Right
Left to right: (10 / 2) * 5 = 25
2) Right to Left
Right to left: 10 / (2 * 5) = 1
6
Example: 10*2-(10/5)+5*2
10
DATA TYPES OF
ARRAY ELEMENTS
G 5 E 1.6 B
11
1D ARRAY
◇ The simplest form of array one can imagine is one art dimensional array
◇ Declaration:
syntax: data _type name of the array[no. of elements]
12
DECLARING THE
LENGTH OF AN
ARRAY
Without predefining it:
13
With predefining it:
14
HOW TO ACCESS AN
ARRAY ELEMENT?
• To access array element just write - array_name[index]
◇ arr
◇ 0 1 2 3 4 . ….n
◇ Method 2:
16
Method 3:
Method 4:
17
POINTS TO REMEMBER
If the number of elements are lesser than the length specified than the rest of
the locations are automatically filled by value.
Easy way to initialize an array with all zeros is given by: int arr[10]={0};At
the time of initialization , never leave these curly brackets empty{}
18
DESIGNATION
INITIALIZATION OF AN
ARRAY
◇ int arr[10]={[0]=1,[5]=2,[6]=3}
19
“
Types of arrays
20
TWO DIMENSIONAL
ARRAYS
At times we need to store the data in form of tables or matrices. For this,
we can use the two dimensional arrays.
22
• Two dimensional array is nothing but array of array.
• syntax :
data_type_ array_name[num_of_rows][num_of_column];
23
THREE DIMENSIONAL (3D)
ARRAY
◇ A 3D array is a multi-dimensional array(array of arrays). A 3D array is a collection
of 2D arrays. It is specified by using three subscripts:Block size, row size and column
size. More dimensions in an array means more data can be stored in that array.
◇ if we add one more dimension here,
i.e, int arr[3][3][3], now it becomes a 3D array.
◇ Declaring of array :
int arr[3][3][3]; //3D array
25
“
Applications illustrating use of arrays
26
EXAMPLE OF UNORDERED
ARRAYS
27
Ordered sequence
29
DESCENDING
ORDER
Output:
30
Thank You!
31