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

Write a program which prompts and reads a list of positive numbers (floats) into

ID: 3531682 • Letter: W

Question

Write a program which prompts and reads a list of positive numbers (floats) into an array, finds the average of the minimum and maximum values in the array, adds this average with each array number and then prints this average number and the modified array. The input list is terminated by a sentinel value of 0. The program should have a function find_minimax_avg() for finding the average number computed from the min and max values in the array, and a procedure array_add() which adds a number to each element of the array.

Explanation / Answer

#include<iostream>
#define MAX 100

using namespace std ;

double find_minimax_avg(float [],int);

void array_add(float,float [], int);

int main(){

int i=0,t=0;

floaat arr[MAX],num,avr=0;

cout<<"Enter the element of array"

do{

cin>>num;

if(num != 0){

arr[i]=num;

i++;

}

}while(num != 0 || i==MAX);

avr=find_minimax_avg(arr,i);

cout<<"Average of minimum and maximum of array is:"<<avr <<endl ;

cout <<endl<< "Enter the number to add elements of array:";

cin >>num;

array_add(num,arr,i);

cout<<endl<<"Modified array is :" ;

for(t=0;t<=i;t++)

cout<<arr[t] ;

return 0;

}


double find_minimax_avg(float arr[],int size){

int t=0;

float min=arr[0],max=arr[0],avr;

for(t=1;t<=size;t++){

if(min>arr[t])

min=arr[t];

if(max<arr[t])

max =arr[t];

}

avr = (min+max)/2;

return avr ;

}

void array_add(float num,float arr[], int size){

int t=0;

for(t=0;t<=size;t++)

arr[t] += x ;


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote