/*
1D as parameters.
Using const for array parameters
*/
#include <iostream>
using namespace std;
void read_array(int [], int);
void print_array(int [], int);
void square_array(int [], int);
int main()
{
	const int n = 100;
	int a[n], size;
	cout << "Enter the size of the array: ";
	cin >> size;
	if (size <= 100)
	{
		read_array(a,size);
		cout << "Before squaring the array: \n";
		print_array(a,size);
		square_array(a,size);
		cout << "After squaring the array: \n";
		print_array(a,size);
	}
	else
		cout << "The size has to be < 100.\n";
	return 0;
}

void read_array(int b[], int size)
{
	cout << "Enter " << size << " integers: ";
	for (int i = 0; i < size; i++)
		cin >> b[i];
}

void print_array(int b[], int size)
{
	cout << "The elements of the array are: \n";
	for (int i = 0; i < size; i++)
		cout << b[i] << "\t";
	cout << endl;
}

void square_array(/*const*/ int b[], int size)
{
	for (int i = 0; i < size; i++)
		b[i] = b[i] * b[i];	
}
