A Presentation About Array Manipulation(Insertion & Deletion in an array)
1.
2. What Is Array ??
Collection Of same type of data.
Data Type ( Int, float, double, char).
Saves data in a sequence.
Examples:
1. Employees Info of an organization.
2. Score of students of a class.
3. Table of daily rainfall data.
4. Temperature record of hours.
3. Three Types Of Array
One Dimensional Array(1-D)
Two Dimensional Array(2-D)
Multi Dimensional Array(A[s1][s2[s3][s4]…)
4. Initialization:
Type Array_name [Size];
Type Array_name [Size] = {list of Values};
Example:
int A[10];
int A[5] ={50,60,70,80,90};
User Define:
int A[n]; [Size of Array declare by User.]
5. Two Dimensional Array(2-D)
Initialization:
Type Array_name[row_size][column_size];
Type Array_name[row_size][column_size]={{s1},{s2},{s3}};
Here s1,s2,s3 refers to sets of number.
Example:
int A[3][3] ;
int A[3][3] = {{10,20,45},{42,79,81},{89,9,36}};
User Define:
int A[r][n];
Value of {r,n} given by user .
6. Initialization:
Type Array_name[s1][s2][s3]…..[sm];
Example:
int survey [3][5][3];
float table [5][4][5][3];
Pros & Cons:
Two dimensional array often
consider as multi dimensional array.
Multi dimensional array is derived
from basic C Language.
Multi Dimensional array
Example
7. One Dimensional Array(1-D):
Loops runs from 0 to n-1 th index.
Sorting might involve if data was ask in sorting mode.
How 1-D array insertion Works:
For 0 to n-1
{input value;(Using scanf)}
int A[5]
8. Insertion In An Array
Two Dimensional Array(2 - D):
Loops runs
for 0 to row – 1
{for 0 to column – 1
input value;(scanf) }
How It works:
int A[3][4];
Step 1 Step 2 Step 3
9. One Dimensional Array(1-D):
User given input.
Search for data
Runs in the loops looking for the given input.
2 Condition: Found or Not found
Found condition:
Example: search: 4 (Found if available).
Not Found (Print Not Found)
ORIGIN (Array) After Deletion
10. Two Dimensional Array(2D)
User Given Input(search: 12)
Process:
Runs inside the loops looking for element.
Condition:
If found delete the input value and replace by ‘0’
Else print not found.
Example: Before After