Array
"Array - It is a collection of variable of same data type and referred under a common name."
In C++ , the declaration of an array is
int a [10] ;
where
int is a Data Type, it can b float, char etc.
a is a Name of the Array (under which it is referred)
[ index number ] is a size of array and it is always started from 0 to size-1.
Two Types Of Array
♣ Single Dimensional Array
♣ Two Dimensional Array
♣ Multi Dimensional Array
# Single Dimensional Array
- it store its elements in linear form.
- it has continuous memory location.
- the size of array is always positive.
Here we declarer an array with size of 5 elements. ( int a[5]; )
a[5] = {55,45,78,67,28}
a[0] = 55
a[1] = 45
a[2] = 78
a[3] = 67
a[4] = 28
Note- 5001 , 5002, .... 5005 is know as address of the array elements (store in a physical memory).
# Two Dimensional Array
- It is stored in a matrices form.
- It is declare-red as int a[row][column];
-
# Multi Dimensional Array
- It is a array two or more array
- Having more then 2 rows and columns.
Ques - Write a program to read 10 elements in an array & display it on screen and calculate its sum.
Program -
Output -
By - Somesh Sah
Comments
Post a Comment