The C++ Data Types
are defined as follows type name[const expression]
int v[10];// is OK, where int size; int v[size];// gives error, size is not const
const int csize=10; double x[csize];// this is OK, elements are x[0] to x[csize-1]
arrays of all types can be declared, except arrays of references:
int& iar[10]; //gives error
initializing an array: int a[ ] = {10,15,25}; double x[csize]={0.1,0.2};// csize = 10
char str[ ]=C++;// str[0] = C, str[1] = +, str[2] = +, str[3] = \0
2-dimensional arrays: double d[2][3] = {
arrays can be referenced and manipulated using pointers:
int ar[10]; int *p=ar;// ar is the same as &ar[0], now p points to the array
for(int i=0; i i++){cout << input an integer value \n;// using iostream.h
cin >> p[i];}// reads the value in ar[i]