Arrays in c

11
ARRAYS IN C (1-Dimensional & 2-Dimensional) By: Anish Kumar 12/CS/60 Haldia Institute Of Technology Introduction 1-D 2-D Programs Operations Limitations Conclusion Bibliography

Transcript of Arrays in c

Page 1: Arrays in c

ARRAYS IN C(1-Dimensional & 2-Dimensional)

By:

Anish Kumar

12/CS/60

Haldia Institute Of TechnologyIntr

od

uc

tio

n 1

-D 2

-D P

rog

ram

s O

pe

ratio

ns

Lim

ita

tio

ns

C

on

clu

sio

n B

iblio

gra

ph

y

Page 2: Arrays in c

Introduction

Array is a derived data type that represents a collection of the

similar types of data with continuous memory locations with

fixed size sequence.

Roles

Efficient storing of large volume of data

Efficient access and manipulation of data

Helpful in viewing complex problem in simpler way

Single name for multiple data

Structured Data Type

Page 3: Arrays in c
Page 4: Arrays in c

1-Dimensional Array

Data_type var_name[Expression]

Data Type is the type of elements to be stored in the array

Var_name is the name of the array like any

Other variables

Expression specifies the number of elements to be stored

In array

Example : int num[10];

char city[9]= “HALDIA”;

char city[9]={ ‘H’,’A’,’L’,’D’,’I’,’A’}

Num[0] =data1

Num[1] =data2

Num[2] =data3

Num[3] =data4

Num[4] =data5

Num[5] =data6

Num[6] =data7

Num[7] =data8

Num[8] =data9

Num[9] =data10

Page 5: Arrays in c

2-DIMENSIONAL ARRAY

0 1 2 3 4

0

1

2

3

4

0 1 2 3 4

0

1

2 7

3

4

int matrix[5] [5]; matrix[2] [1] =

7

0 1 2

0 1 2 3

1 4 5 6

2 7 8 9

3 10 11 12

int array [4][5];

or

Int [][] array ={ {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12} };

Page 6: Arrays in c

2-Dimensional Array

Page 7: Arrays in c

Applications

Matrix Problem

Solving different algorithms, graph & tree problem

Parse Matrix

Storing and searching of large amount of data

Stack, Queue

Array of pointers, Dynamic Arrays

Page 8: Arrays in c

OPERATIONS IN ARRAY

INSERTION

DELETION

MERGING TWO ARRAYS

TRAVERSING

SORTING

SEARCHING

Page 9: Arrays in c

Limitations

Wastage of memory space. We cannot change size of

array at the run time.

It can store only similar type of data.

Sometimes it is not easy to operate with many index

arrays.

Page 10: Arrays in c

Conclusion

Array has added a new flavour to the programming, the

efficiency of C language has reached to zenith in terms of

efficient storing , accessing and manipulation of data, speed and

reliability.

Bibliography

ANSI C by E Balagurusamy

http://www.slideshare.net

Wikipedia

Page 11: Arrays in c

Please!!

Any

Questions?

Thank

you!!