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

2. (60) Write a program that will use the following function prototypes: int rea

ID: 3599206 • Letter: 2

Question

2. (60) Write a program that will use the following function prototypes: int readAbsoluteData(double data[D; Ilask user for number of points, read in points and store the absolute value of each entered value in data and return number of points void sort(double datal], int numpts )://sort the values from lowest to highest double bigSum(double data, int numpts); //return the sum of all values greater than 10 In main, call readAbsoluteData to read in the number of points along with the absolute value of the data points. In sort, the data read in by readAbsoluteData is to be sorted. In bigSum, find the sum of all values greater than 10. Each function including main is worth 15 points. Don't try to enter all the code and then debug. Instead work on main and readAbsoluteData and get that to work before going on to the other functions. Save the source file as prog2.cpp. Be sure to add your name as a comment at the beginning of each program!! Be sure to have your name printed out in each program and sign the honor code below. I have neither given nor received aid on this graded examination Print your name

Explanation / Answer

the code is as follows :

-----------------------------------------------------------------------------------------------------------------------

#include <iostream>

int readAbsoluteData(double data[],int size){
for( int i=0;i<size;i++){
    std :: cout << " Enter a double value";
    std :: cin >> data[i];
}
return size;
}

void sort(double data[], int size){
double temp;
for(int i =0;i<size;i++){
    for(int j=0;j<size;j++){
      if(data[i]>data[j]){
   temp = data[i];
   data[i] = data[j];
   data[j] = temp;
      }
    }
}
}

double bigSum(double data[], int size){
double sum =0.0;
for( int i =0;i<size;i++){
    if( data[i] > 10)
      sum = sum + data[i];
}
return sum;
}

int main(){
double *data;
int size;
std :: cout << " Enter the number of points";
std :: cin >> size;
data = new double(size);
size = readAbsoluteData(data,size);
sort(data,size);
std :: cout << " Big Sum is :" << bigSum(data,size)<<" ";
return 0;
}
/*
int readAbsoluteData(double data[],int size){
data = new double(size);
for( int i=0;i<size;i++){
    std :: cout << " Enter a double value";
    std :: cin >> data[i];
}
return size;
}
*/

---------------------------------------------------------------------------------------------------------------------

when i create memory in the readAbsoluteData() function the memory is getting deleted after the functin scope is over the memory getting cleared so i found this way.

If i found other ways I'll comment back

/* hope this helps */

/* if any queries please comment */

/* thank you */

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote