#include <iostream>
#include <cstdlib>
using namespace std;
const int N = 100;
const int MAX_RAND = 5;
void InitArray(int (&)[N], int);
void PrintArray(int (&)[N], int);
void MultiplyElements(int (&)[N], int);
int main()
{
int arr[N];
int n;
cout << "Enter array size: ";
cin >> n;
cout << endl;
InitArray(arr, n);
PrintArray(arr, n);
cout << "Array after an operation: ";
MultiplyElements(arr, n);
PrintArray(arr, n);
return 0;
}
void InitArray(int (&arr)[N], int n)
{
for(int i = 0; i < n; i++)
{
arr[i] = rand() % MAX_RAND;
}
cout << "The array is initialized" << endl;
}
void PrintArray(int (&arr)[N], int n)
{
cout << endl;
for(int i = 0; i < n; i++)
{
cout << ' ' << arr[i];
}
cout << endl;
}
void MultiplyElements(int (&arr)[N], int n)
{
for(int i = 0; i < n; i++)
{
arr[i] = pow(arr[i], 2) < 16 ? arr[i] * 3 : arr[i];
}
}