Today’s Topic:
1. Array
Course No.: CSE 1281
Course Title: Computer and
Programming Language
Credit: 3.00
1
Introduction to Array
> So far, we have used only the fundamental data types, namely int, float, char and
double.
> However, main problem with them is that they can store only one value.
> Therefore, we need a powerful data type that can store large volume of data.
> Array is a derived data type that can serve the purpose.
> An array is a fixed-size sequenced collection of elements of the same data type.
2
One-Dimensional Arrays
> Consider the following example –
int number[5];
3
Initialization of One-Dimensional Array
4
Average of n numbers
5
Sorting
6
Bubble Sorting
Check the Class
7
Bubble Sorting Code
Check the link: Codes (C Programming) - Google
Drive
8
Selection Sorting
Check the Class
9
Selection Sorting Code
Check the link: Codes (C Programming) - Google
Drive
10
Insertion Sorting
Check the Class
11
Insertion Sorting Code
Check the link: Codes (C Programming) - Google
Drive
12
Program to find the largest of n numbers
13
Determining the Frequency of Elements
14
Determining the Frequency of Elements
15
Two-Dimensional Array
> So far, we have discussed the array variables that can store a list of values.
> There could be situations where a table of values will have to be stored.
16
Initializing Two-Dimensional Array
17
Initializing Two-Dimensional Array
> If the value is missing in the initializer, it is automatically set to zero.
> When all the elements are to be initializer to zero, the following shortcut method can be
used.
18
Adding Two Matrices
19
Adding Two Matrices
20
Adding Two Matrices
21
Multiplication of Two Matrices
22
Multiplication of Two Matrices
23
Multiplication of Two Matrices
24