Array
Array and Size
#include <iostream>

int main(int argc, char *argv[])
{
	const int size = 10;
	int array[size];

	//initialize array
	for(int i = 0; i < size; i++)
		array[i] = i*i;

	//display array
	for(int i = 0; i < size; i++)
		std::cout<<array[i]<<" ";
	std::cout<<std::endl;

	//display array size
	std::cout<<"Memory size: "<<sizeof(array)<<std::endl;
	std::cout<<"Number of elements: "<<sizeof(array)/sizeof(*array)<<std::endl;

	return 0;
}
			
Bounds Checking
#include <iostream>

int main(int argc, char *argv[])
{
	const int size = 5;
	int array[size];

	for(int i = 0; i < size; i++)
		array[i] =  10*i;

	for(int i = 0; i < 10; i++)
		std::cout<<array[i]<<std::endl;

	return 0;
}
			
Array Initialization
#include <iostream>

void display(int array [], int size)
{
	for(int i = 0; i < size; i++)
		std::cout<<array[i]<<" ";
	std::cout<<std::endl;
}

int main(int argc, char *argv[])
{
	const int size = 5;

	//array initialization
	int array[size] = {10, 20, 30, 40, 50};
	display(array, sizeof(array)/sizeof(*array));

	//partial array initialization
	int array2[size] = {10, 20};
	display(array2, size);

	//empty initialization
	int array3[size] = {};
	display(array3, size);

	//no initialization
	int array4[size];
	display(array4, size);

	//implicit array sizing
	int array5[] = {10, 20, 30, 40};
	display(array5, 4);

	return 0;
}
			
Assignment
#include <iostream>

void display(int array [], int size)
{
	for(int i = 0; i < size; i++)
		std::cout<<array[i]<<" ";
	std::cout<<std::endl;
}

int main(int argc, char *argv[])
{
	const int size = 5;
	int array[size] = {10, 20, 30, 40, 50};

	int array2[size];

	std::cout<<"Address of array: "<<array<<std::endl;
	std::cout<<"Address of array2: "<<array2<<std::endl;

	//array2 = array;//compile error
	
	for(int i = 0; i < size; i++)
		array2[i] = array[i];
	display(array2, size);

	return 0;
}
			
Variable Size of Array
#include <iostream>

int main(int argc, char *argv[])
{
	int size;
	std::cout<<"Enter the size of the array: "<<std::endl;
	std::cin>>size;

	int array[size];

	std::cout<<sizeof(array)/sizeof(*array)<<std::endl;

	return 0;
}
			
Pass Array to Function
#include <iostream>

void display(int array[], int s)
{
	for(int i = 0; i < s; i++)
		std::cout<<array[i]<<" ";
	std::cout<<std::endl;
}

void init(int array[], int s)
{
	for(int i = 0; i < s; i++)
		array[i] = 10*i;
}

int main(int argc, char *argv[])
{
	const int size = 5;
	int array[size];

	init(array, size);
	display(array, size);

	return 0;
}
			
Two Dimensional Array
#include <iostream>

const int rowSize = 3, columnSize = 4;

void display(int array[][columnSize], int rowSize)
{
	for(int i = 0; i < rowSize; i++)
	{
		for(int j = 0; j < columnSize; j++)
			std::cout<<array[i][j]<<" ";
		std::cout<<std::endl;
	}
}

void init(int array[][columnSize], int rowSize)
{
	for(int i = 0; i < rowSize; i++)
		for(int j = 0; j < columnSize; j++)
			array[i][j] = i*10+j;
}

int main(int argc, char *argv[])
{
	int array[rowSize][columnSize];

	init(array, rowSize);

	std::cout<<"Total size: "<<sizeof(array)<<" "<<sizeof(array)/sizeof(*array[0])<<std::endl;
	std::cout<<"Row size: "<<sizeof(*array)<<" "<<sizeof(*array)/sizeof(*array[0])<<std::endl;

	display(array, rowSize);

	return 0;
}
			
Template
#include <iostream>

template <class T>
void init(T array[], int size)
{
	for(int i = 0; i < size; i++)
		array[i] = 10*i;
}

template <class T>
void display(T array[], int size)
{
	for(int i = 0; i < size; i++)
		std::cout<<array[i]<<" ";
	std::cout<<std::endl;
}

int main(int argc, char *argv[])
{
	const int size = 5;
	double array[size];

	init(array, size);
	display(array, size);

	return 0;
}
			
Reference