Professional Documents
Culture Documents
Unit 5
Unit 5
Session 5
Agenda
• Recap
• Arrays
• Single dimensional array and 2-Dimensional array
• Matrix Operation
• Strings
• String- An Array
• Binary Search
2
Recap
• Branching
If Statement
If .. Else Statement
Nesting If.. Else Statement
• Looping
If Statement
For.. Statement
While Statement
Do..While Statement
• Switch Statement
Break Statement
3
C Arrays
• An Arrays can store a fixed-size sequential collection
of elements of the same type
An array is used to store a collection of data
An array as a collection of variables of the same
type
All arrays consist of contiguous memory locations
To access a value, one requires Array name and
index number
C Arrays
• An Arrays can store a fixed-size sequential collection
of elements of the same type
An array is used to store a collection of data
An array as a collection of variables of the same
type
All arrays consist of contiguous memory locations
To access a value, one requires Array name and
index number
C Multidimensional Array
• C programming language allows multidimensional
arrays
• Declaring a multidimensional array
data type array_name[size1][size2]….[sizeN];
An example of 3-Dimensional integer array
int Roll_number[2][2][1]
2-dimensional arrays are widely used
2-D array is represented as a matrix with rows
and column
int Roll_Number[4][2] is a 2-D array with 4 Row and 2 Column
C 2-D Array
• Initialising a 2-D array
int Roll_Number[4][2]={{1,2},{3,4},{5,6},
{7,8}};