Download presentation
Presentation is loading. Please wait.
1
Chapter 7: Array
3
Array: Introduction Many application require the processing of multiple data items that have common characteristics Array is the best option of variable to store such data which shares common name An array is a collection of data items, all of the same type, accessed using a common name. An array is a datastructure containing number of data value, all of which have the same datatype Common name is followed one or more subscripts
4
Array: Declaration Similar to normal variable but size should be defined Syntax: data_type array_name[size] Example: int roll[50];
5
Array: initialization
6
Getting values from user in array
Can be done using loop Eg:
8
Example 1: Program to enter n element in array and display their sum
9
Example 2: Program to enter array and display in reverse order
Program to find maximum and minimum number in array Program search a element in array
10
Example 3: Program to convert lowercase to uppercase
11
Best Appreciation Ever Made
12
Multi-dimentional Array
Syntax: data_type array_name[size1][size2]….[] Can be effectively used using n-nested loop
13
Multi-dimentional array example
Program to add, subtract two matric Program to Transpose matrix Program to find lower and upper triangular matrix Program to replace all no diagonal element to zero Program to find sum of all element in matrix Program to find sum of diagonal element
14
Sorting – Bubble sort
15
Bubble – Sort Implementation
16
Searching – Linear Search
17
Searching – binary search
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.