0% found this document useful (0 votes)
15 views

Arrays

Uploaded by

K A Shiekh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Arrays

Uploaded by

K A Shiekh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Arrays

LECTURE 21
BY: KAISER A SHIEKH
LECTURER COMPUTER SCIENCE
Array
• Array is a collection of homogenous data items at contiguous memory
locations under a single name separated by unique index.
• Array is a collection of same type of variables arr
• Syntax for declaration : 0 arr [0]
datatype ArrayName[size]; 1 arr[1]
2 arr[2]
• Example : arr[3]
3
int arr[10]; // creates an array of 10 integers 4 arr[4]
5 arr[5]
6 arr[6]
7 arr[7]
8 arr[8]
9 arr[9]
Array initialization
• Array initialization arr

int arr[10]= { 10,20,30,40,50,60,70,80,90,100,110}; 0 10


20
OR 1
30
2
int arr[]={10, 20,30,40,50,60,70,80,90,100,110}; 3
40
60
4
70
5
80
6
90
7
100
8
110
9
Accessing specific array block
• Array blocks can be accessed using indices arr
• Eg: ArrayName [ index] = value ; 0 10 arr [0]
20 arr[1]
• arr[5]= 200; 1
30 arr[2]
2
40 arr[3]
3
60 arr[4]
4
70 arr[5]
5
80 arr[6]
6
90
7 arr[7]
100
8 arr[8]
110
9 arr[9]

You might also like