Articles added in Mathematics Lab | Cyber Lab is now open | Astronomy Lab is now open | VLSI Lab is now open | 120 SEO Tips article published | More exciting articles coming soon!

4.1 Introduction to Arrays

We know that only one value can be stored in a variable data-type. If we want to store several items of the same type, then we’ll have to declare as many variables as the number of items. Creating and maintaining so many variables is a difficult task. This problem can be solved by creating an array.
An array is a collection of items of the same type that will be referred by a single name. C++ supports one and multi-dimensional arrays.

data_type array_name[size1][size2]….[sizen];

Note:– above declaration is for n dimensional array. size1,size2,… should be a positive integer constant only.

For e.g.
int a[100];
int b[2][3];
char c[5];

int n=4;
int d[n]; Not valid

a and c are one dimensional while b is 2 dimensional array.
Elements of “a” are a[0],a[1],….a[99].
All the above are int variables.

CACKLE comment system

Programming Resources
Computer Networking Fundamentals Android Application