Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Your program must contain the three functions listed below, in a single file

ID: 3743872 • Letter: 1

Question

1. Your program must contain the three functions listed below, in a single file named proj1.cpp: a) main -This function must appear first in your project cpp file, and will perform the following tasks: rray etements to allocate. This number must be between 100 r. if the user enters aa value outsi Dynamically allocate an array with the number of elements requested by the user, by calling the function allocateArray (described below). After allocating the array, write to stdout and to the output file (out.txt) a line of the form (see sample output file): Allocated array with X elements Open input file nums.txt (must be so named) and read the integers in that file (one integer per line). .. Process the file as you go. You may not read the file more than once When you have filled the existing array, call the calcAvg function and output the average of the integers read up to that point (as a double); and invoke function allocateArray to increase the size of the array by 30%, up to a maximum of 500 elements (enforced in the allocateArray function) Example: The user asks for 200 initial elements. Once you have read and placed into the array the 200th item, calculate and output the average of the values read so far, and invoke allocateArray to expand the array size-new size is 260 (200 * 130%). Output at this stage should be of the form: i. Average so far is YY.ZZ-Array size now X i. Continue to process the file. Upon inserting the 260th item (reaching the capacity of the array), repeat the call, to create an array of size 338 (260 * 130%) ii. Repeat this process until the file has no more integers (the number of integers in the file will be 500 elements or fewer). The number of integers read, and the calculated average must be output before exiting the program: X integers were read and the average was YYY.zzz

Explanation / Answer

hi please follow my instructions to fullfill our requirement.

C++ Source code:-

=============

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
double arrayOps(double arraytOfDoubles[],int arraysize,string opType);
int main()
{
cout<<"Enter The Size of Array:"<<endl;
int arraysize=0;
cin>>arraysize;
double *arraytOfDoubles=new double[arraysize];
cout<<"Enter The "<<arraysize<< "Elements"<<endl;
for(int i=0;i<arraysize;i++)
{
cin>>arraytOfDoubles[i];
}
double calcsum=0;
calcsum=arrayOps(arraytOfDoubles,arraysize,"calcSum");
cout<<"The Sum Of Array Elements is :"<<calcsum<<endl;
double calcAvg=0;
calcAvg=arrayOps(arraytOfDoubles,arraysize,"calcAvg");
cout<<"The Average Of Array Elements is :"<<calcAvg<<endl;
double calcsumSquares=0;
calcsumSquares=arrayOps(arraytOfDoubles,arraysize,"calcSumSquares");
cout<<"The Sum Of Squares of Array Elements is :"<<calcsumSquares<<endl;
return 0;
}
double arrayOps(double arraytOfDoubles[],int arraysize,string opType)
{
if(opType=="calcSum")
{
  double sum=0;
  for(int i=0;i<arraysize;i++)
  {
   sum=sum+arraytOfDoubles[i];
  }
  return sum;
}                                                
else if(opType=="calcAvg")
{
  double avg=0,sum=0;
  for(int i=0;i<arraysize;i++)
  {
   sum=sum+arraytOfDoubles[i];
  }
  avg=sum/arraysize;
  return avg;                  
}
else if(opType=="calcSumSquares")
{
  double square=0,sum=0;
  for(int i=0;i<arraysize;i++)
  {
   square=arraytOfDoubles[i]*arraytOfDoubles[i];
   sum=sum+square;
  }
  return sum;
}
return 0;
}


please wait i will you provide the the sample output and screenshot