Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Yogesh Neopaney Assistant Professor Department of Computer Science

Similar presentations


Presentation on theme: "By Yogesh Neopaney Assistant Professor Department of Computer Science"— Presentation transcript:

1 By Yogesh Neopaney Assistant Professor Department of Computer Science
Array By Yogesh Neopaney Assistant Professor Department of Computer Science

2 An Array is a user-defined data type that stores related information together.
All the information stored in an array belongs to the same data type.

3 Declaration of Arrays 3 things are needed before declaring an array
Data type- The kind of the values it can store, example int, char, float, double. Name – The name of an array. Size- The maximum number of values that the array can hold.

4 Syntax for Declaring an array
Data_Type Name [Size]; Example- Int marks[10]; The array will be stored as shown below:- 1st Element 2nd Element 3rd Element 4th Element 5th Element 6th Element 7th Element 8th Element 9th Element 10th Element

5 Storing Values in an Array
Initialize the Elements during declaration. Input Values for the elements from the keyboard. 3. Assign values to Individual

6 Operation on Arrays Traversing an array
Inserting an Element in an array Searching an element in an array Deleting an element in an array Merging two arrays Sorting an array in ascending or descending order.

7 Advantages and Disadvantages of an array
It is used to represent multiple data items of same type by using only single name. It can be used to implement other data structures like linked lists, stacks, queues, trees, graphs etc. 2D arrays are used to represent matrices.

8 Disadvantages We must know in advance that how many elements are to be stored in an array. Array is static structure. It means that array is of fixed size. Since array is of fixed size, if we allocate more memory than requirement then the memory space will be wasted and if we allocate less memory than requirement, then it will create problem.

9 Thank You


Download ppt "By Yogesh Neopaney Assistant Professor Department of Computer Science"

Similar presentations


Ads by Google