






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







2
finite collection of similar elements stored in adjacent memory
locations.
Decleration of the Arrays: (In C)
the array name, the element type and the array size.
Examples:
/ / one-dimensional
arrays
int a[20],
b[3],c[7];
float f[5], c[2];
char m[4], n[20];
Initialization of an array is the process of assigning initial values.
Examples:
float, b[3]={2.0, 5.5, 3.14};
char name[4]=
{โEโ,โmโ,โrโ,โeโ}; int c[10]={0};
4
5
7
#include<iostream.h>
int main ()
int i,n; int * p;
cout << "How many numbers would you like to type?
"; cin >> i;
p= new int[i]; / / it takes memory at run-time from
Heap if(p == NULL)
cout << "Error: memory could not be allocated";
else
for(n=0; n<i; n++)
cout << "Enter number:
"; cin >> p[n];
int*k=p; / / to hold the base address
of dynamic array
cout << "You have entered: \n";
for(n=0; n<i; n++) cout << *k<< ", "; k++;
cout<<"\n"; delete[] p; / / it release the memory to send it back to
Heap
return 0;
Sample code for
Dynamic
Array declaration
7
9
a) Traversing in Linear Array
1
0
c) Deleting from Linear
Array