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

Arrays: Prepared by B.M.Brinda

Arrays allow storing similar data under a single variable name. This is useful for handling large amounts of homogeneous data more efficiently than creating individual variables. Arrays store data consecutively in memory, making searching faster. An array is declared with a data type, array name, and size. Elements are accessed using indexes that reference the array location. The array size is fixed at creation. Arrays can have one or multiple dimensions to organize related data.

Uploaded by

Brinda BM
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Arrays: Prepared by B.M.Brinda

Arrays allow storing similar data under a single variable name. This is useful for handling large amounts of homogeneous data more efficiently than creating individual variables. Arrays store data consecutively in memory, making searching faster. An array is declared with a data type, array name, and size. Elements are accessed using indexes that reference the array location. The array size is fixed at creation. Arrays can have one or multiple dimensions to organize related data.

Uploaded by

Brinda BM
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

ARRAYS

Prepared By
B.M.Brinda

WHY ARRAYS?

Why do we need arrays?

To handle similar types of data.

Imagine a world without arrays.

Example, If the user want to store marks of 100


students, User may create 100 variables to store
data !!!

INTRODUCTION

An array is a sequence of data item of


homogeneous value(same type).
Each block of array is stored consecutively in
memory.
Huge amount of data can be stored under
single variable name.
Searching of data item is faster.

ARRAY DECLARATION

Syntax:
Data type arrayName [ arraySize ];

Examples:

int list[10];
char num[15];
float hat[20];

ARRAY INITIALIZATION
Example:

int num[10];

num[0]references the first element in the array.


num[9]references the last element in the array.

int num[6]={2,4,6,7,8,12};

Individual elements can also be initialize as:

num[0]=2;
num[1]=4;
num[2]=6;
num[3]=7;
num[4]=8;
num[5]=12;

LENGTH OF ARRAYS

Once an array is created, its size is fixed. It


cannot be changed.

For Example,
int arr[10];

You can not insert any number to arr[11] location because it


is not initialized.

ONE DIMENSIONAL ARRAY

MULTI DIMENSIONAL ARRAY

You might also like