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

Develop a program containing 4 separate C++ functions to perform the following o

ID: 3811571 • Letter: D

Question

Develop a program containing 4 separate C++ functions to perform the following on a one-dimensional integer array LIST of dimension N: 1. Determine (i.e. "return") the highest value in LIST. Determine (i e. "return") the lowest value in LIST. 3. Determine (i.e. "return") the sum of all the items in LIST 4. Determine (i.e. "return") the average of the values in LIST after eliminating the lowest and the highest values. This function should invoke some or all of the other 3 functions. Develop a C++ program that will add the corresponding elements of two 2-dimensional arrays X and Y to produce the 2-dimensional array Z. Arrays X, Y, Z have the same dimension [M] [N] (i.e. M rows and N columns).

Explanation / Answer

1)

#include <iostream>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
void Min(int *array, int size)
{ int min;
min=array[0];
for(int i=0;i<size;i++)
{
if(array[i]<min)
min=array[i];
  
}
cout<<"Minimum Number is = "<<min<<endl;

}

void Max(int *array, int size)
{ int max;
max=array[0];
for(int i=0;i<size;i++)
{

if(array[i]>max)
max=array[i];
}

cout<<"Maximum Number is = "<<max<<endl;
}
int sum(int *array, int size)
{ int sum1;
sum1=0;
for(int i=0;i<size;i++)
{
sum1+=array[i];
}
cout<<"Sum of an array is = "<<sum1<<endl;
return sum1;
}


void sumavg(int *array, int size)
{ int sum1;
sum1=0;
sort(array, array+10);
  
int arr2 [size];

for(int i=1;i<size-1;i++)
{
arr2[i-1]=array[i];
cout<<arr2[i-1];
}
sum1=sum(arr2,size-2);
double avg= (double)sum1/(size-2);

cout<<"Sum of an array is = "<<sum1<<endl;
cout<< "avg is = "<<avg<<endl;

}


int main()
{
int array[10];
int x;
cout<<"Enter Array Value"<<endl;
for(int i=0;i<=9;i++)
{
cin>>x;
       array[i]=x;   
}
Min(array,10);
Max(array,10);
sum(array,10);
sumavg(array,10);
return 0;
}

2)

#include <iostream>
using namespace std;
  
int main(){
int rows, cols, i, j;
int x[50][50], y[50][50], z[50][50];

cout <<"Enter Rows and Columns of Matrix ";
cin >> rows >> cols;
  
cout <<"Enter first Array of size "<<rows<<" X "<<cols;
// first array
for(i = 0; i < rows; i++){
for(j = 0; j < cols; j++){
cin >> x[i][j];
}
}
// Input second Array
cout <<" Enter second Array of size "<<rows<<" X "<<cols;
for(i = 0; i < rows; i++){
for(j = 0; j < cols; j++){
cin >> y[i][j];
}
}
/* add */

for(i = 0; i < rows; i++){
for(j = 0; j < cols; j++){
z[i][j] = x[i][j] + y[i][j];
}
}
  
cout <<"Sum of two array ";
for(i = 0; i < rows; i++){
for(j = 0; j < cols; j++){
cout << z[i][j] << " ";
}
cout << " ";
}

return 0;
}