in C++ and also each function has its own main function so please do the main function as well. Previously when i asked the question the person only did the function and didn't do the main function so please help me do it.

I have included my code and screenshots in this answer. In case, there is any indentation issue due to editor, then please refer to code screenshots to avoid confusion.
------------------function-1-1.cpp----------
int sum_array(int array[], int n) //returns sum of array
{
if(n < 1) //if n is less than 1, then return
0
return 0;
int sum = 0;
for(int i = 0; i < n; i++)
{
sum = sum + array[i]; //add each
element to sum
}
return sum;
}
------------------main-1-1.cpp----------
#include <iostream>
#include "function-1-1.cpp" //include function
using namespace std;
int main()
{
int arr1[6] = {2, 3, 4, 6, 11, 4}; //sample test
arays
int arr2[8] = {12, 13, 48, 6, 11, 4, 7, 10};
cout << "\nThe array 1 is: ";
for(int i = 0; i < 6; i++) //print array
{
cout << arr1[i] << ",
";
}
cout << "\nThe sum is: " <<
sum_array(arr1, 6) << endl; //print sum
cout << "\nThe array 2 is: ";
for(int i = 0; i < 8; i++) //print array
{
cout << arr2[i] << ",
";
}
cout << "\nThe sum is: " <<
sum_array(arr2, 8) << endl; //print sum
return 0;
}
------------------function-1-2.cpp----------
double average(int array[], int n) //returns average of
array
{
if(n < 1) //if n is less than 1, then return
0.0
return 0.0;
double average;
int sum = 0;
for(int i = 0; i < n; i++)
{
sum = sum + array[i]; //add each
element to sum
}
average = (double)sum/n; //type cast sum from int to
double
return average; //return average
}
------------------main-1-2.cpp----------
#include <iostream>
#include "function-1-2.cpp"
using namespace std;
int main()
{
int arr1[6] = {2, 3, 4, 6, 11, 4}; //sample test
arays
int arr2[8] = {12, 13, 48, 6, 11, 4, 7, 10};
cout << "\nThe array 1 is: ";
for(int i = 0; i < 6; i++) //print array
{
cout << arr1[i] << ",
";
}
cout << "\nThe average is: " <<
average(arr1, 6) << endl; //print average
cout << "\nThe array 2 is: ";
for(int i = 0; i < 8; i++) //print array
{
cout << arr2[i] << ",
";
}
cout << "\nThe average is: " <<
average(arr2, 8) << endl; //print average
return 0;
}
------------------function-1-3.cpp----------
int count(int array[], int n, int number) //returns count of
number in array
{
if(n < 1) //if n is less than 1, then return
0
return 0;
int count = 0;
for(int i = 0; i < n; i++)
{
if(array[i] == number) //check if
array element is same as number
count++; //If
yes then increment count
}
return count; //return count
}
------------------main-1-3.cpp----------
#include <iostream>
#include "function-1-3.cpp"
using namespace std;
int main()
{
int arr[8] = {12, 10, 48, 6, 10, 4, 12, 10}; //sample
test aray
cout << "\nThe array is: ";
for(int i = 0; i < 8; i++) //print array
{
cout << arr[i] << ",
";
}
cout << "\nThe count of is 10 is : " <<
count(arr, 8, 10) << endl; //print count of 10 in array
cout << "\nThe count of is 12 is : " <<
count(arr, 8, 12) << endl; //print count of 12 in array
cout << "\nThe count of is 3 is : " <<
count(arr, 8, 3) << endl; //print count of 3 in array
return 0;
}
------------------function-1-4.cpp----------
int sum_two(int array[], int secondarray[], int n) //returns sum
of two arrays
{
if(n < 1) //if n is less than 1, then return
0
return 0;
int sum = 0;
for(int i = 0; i < n; i++)
{
sum = sum + array[i] +
secondarray[i]; //add both elements at index i to sum
}
return sum; //return sum
}
------------------main-1-4.cpp----------
#include <iostream>
#include "function-1-4.cpp"
using namespace std;
int main()
{
int arr1[6] = {10, 20, 30, 40, 50}; //sample test
arays
int arr2[8] = {2, 4, 6, 8, 10};
cout << "\nThe array 1 is: ";
for(int i = 0; i < 5; i++) //print array
{
cout << arr1[i] << ",
";
}
cout << "\nThe array 2 is: ";
for(int i = 0; i < 5; i++) //print array
{
cout << arr2[i] << ",
";
}
cout << "\nThe sum of two arrays is : "
<< sum_two(arr1, arr2, 5) << endl; //print sum of two
arrays
return 0;
}
------------------Code screenshots----------








------------------Output----------

------------------------------------------
I hope this helps you,
Please rate this answer if it helped you,
Thanks for the opportunity
in C++ and also each function has its own main function so please do the main...
(C++)Write a function that accepts an int array and the array’s size as arguments.The function should create a new array that is twice the size of the argument array.The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0.The function should return a pointer to the new array.Demonstrate the function by using it in a main program that reads an integer N (that is not more...
1. All functions should be written AFTER the main procedure. 2. A function prototype should be written for each function and placed BEFORE the main procedure. 3. Each function should have a comment explaining what it does. 4. Each function parameter should have a comment explaining the parameter. 5. Prompt for the number of elements of the list. 6. Allocate an array whose size equals the number of elements specified by the user. 7. Read into the array the elements...
a) Write a function called print_doubles that prints the first n elements of an array of doubles. Assume the array is long enough. Example: double v[5] = {1,2,3,4,5}; print_doubles(v, 5); // prints [1,2,3,4,5] b) Write a function with the following signature: void get_min_max(const double values[], int n, double *pmin, double *pmax); that returns in output parameters *pmin the value of the minimum element in array values and in *pmax the maximum element. Parameter n represents the size of array values....
in c++ please Assignment Instructions: MAIN FUNCTION: Ask the user how many students were surveyed. Call a function called makeArray to define an array of integers with the number of elements equal to the number of students surveyed. Call a function called getStudentData to allow the user to enter the number of hours each student spent watching Netflix into the array. Call a function called getAverage to calculate and display the average of the hours entered. Call a function called...
Write the interface (.h file) of a class Accumulator containing:A data member named sum of type integer.A constructor accepting an integer parameter.A function named getSum that accepts no parameters and returns an integer.A function named add that accepts an integer parameter and returns no value.class Accumulator{int sum;Accumulator(int);int getSum ();void add (int);};Write the implementation (.cpp file) of the Accumulator class of the previous exercise. The full specification of the class is:An data member named sum of type integer.A constructor that accepts...
Write a C++ function binsearch that carries out the binary search algorithm on a sorted array of integers. Your function takes as parameters an array of integers (sorted in increasing order), the size of the array, and a target integer to search for. The function returns the index of the target in the array, and returns -1 if the target is not in the array. The file main1.txt on the webpage contains code that generates a specific array of integers...
Fix this C++ code so that the function prototypes come before main. Main needs to be declared first. Then call to the functions from inside of main. #include<cstdlib> using namespace std; //prompt user for input void getGrades(int gradeArray[],int size) { for(int i=0; i<size; i++) { cout<<"Enter the grade "<<i+1<<": "; cin>>gradeArray[i]; } } // finding average of all numbers in array float computeAverage(int numbers[],int size) { float sum=0; for(int i=0; i<size; i++) { sum = sum + numbers[i]; //compute sum...
Write a C++ function, lastLargestIndex that takes as parameters an int array and its size and returns the index of the "last occurrence" of the largest element in the array. Include another function to print the array. Also, write a program to test your function. [HINTS) Create an array of size 15 in the main function and initialize it with the values shown in the below sample output. Pass the array and its size to function lastLargestindex; function lastLargestindex returns...
must be done in C
You will implement a function that matches one of the prototypes below. int maxArray(int size, int* arr); int maxArray(int size, int arr]); The first parameter is the number of elements in the array. The second parameter is an address to the beginning of an int array. In the body of the function, use a looping structure to identify and return the maximum (largest number) of the array. NOTE: The maximum of the same number, say...
22:217 learn-ap-southeast-1-prod-fleet02-xythos.s3-ap-southeast-1.am purse Code: CSCI1540 (2019-20, Term 1) Page 2 of 6 2. (20%) Write a program (file name: Q2.cpp) with a function of int distinct (int *p, int n); where the parameter pointer p is the base address of an array of size n. The function returns the number of distinct (unique) elements in the array. E.g., suppose array x has contents {1,6,4,6,1). Then the call distinct (x, 5) should return 3. (The three distinct elements are 1,6, 4.)...