#include <iostream>
#include <cstdlib>
#include <ctime>
typedef int datatype;
void init_array(datatype* arr, int SIZE)
{
for (int i = 0; i < SIZE; ++i)
arr[i] = rand() % 100;
}
void show_array(datatype* arr, int SIZE)
std::cout << "array: ";
std::cout << arr[i] << " ";
std::cout << "\n";
datatype find_sum(datatype* arr, int SIZE)
datatype sum = 0;
sum += arr[i];
return sum;
int main()
std::cout << "enter a size of the array: ";
int SIZE;
std::cin >> SIZE;
datatype *arr = new datatype[SIZE];
srand(time(NULL));
init_array(arr, SIZE);
show_array(arr, SIZE);
std::cout << "sum of elements: " << find_sum(arr, SIZE) << "\n";
delete[] arr;
return 0;
#include <iostream>
#include <cstdlib>
#include <ctime>
typedef int datatype;
void init_array(datatype* arr, int SIZE)
{
for (int i = 0; i < SIZE; ++i)
arr[i] = rand() % 100;
}
void show_array(datatype* arr, int SIZE)
{
std::cout << "array: ";
for (int i = 0; i < SIZE; ++i)
std::cout << arr[i] << " ";
std::cout << "\n";
}
datatype find_sum(datatype* arr, int SIZE)
{
datatype sum = 0;
for (int i = 0; i < SIZE; ++i)
sum += arr[i];
return sum;
}
int main()
{
std::cout << "enter a size of the array: ";
int SIZE;
std::cin >> SIZE;
datatype *arr = new datatype[SIZE];
srand(time(NULL));
init_array(arr, SIZE);
show_array(arr, SIZE);
std::cout << "sum of elements: " << find_sum(arr, SIZE) << "\n";
delete[] arr;
return 0;
}