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

//This program is going to show the sum, average and print outputs in order. #in

ID: 3759494 • Letter: #

Question

//This program is going to show the sum, average and print outputs in order.
#include <iostream>
#include <string>
using namespace std;

int main()
{
   int i;
   int Array[10];

   for (i = 0; i < 10, i++)
   {
       cin >> Array[i];
   }

   highest = Array[0];
   lowest = Array[0];

   for (i = 1; i < 10; i++)
   {
       if (Array[i] > highest) highest = Array[i];
       if (Array[i] < lowest) lowest = Array[i];
   }

   system("pause");
   return 0;
}

Modify this program to meet these requirements:

Write a program that lets the user enter 10 values into an array. The program should then display the largest, the smallest, the sum, and the average values.

Output should print:

The values are as following:

The smallest value is:

The highest value is:

The sum is:

The average is:

The values printed should be sorted from least to greatest.

~Please show a screenshot of the working solution

Explanation / Answer

#include <iostream>

#include <string>

using namespace std;

int main()

{

int i;

int Array[10];

int sum=0, avg;

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

{

cin >> Array[i];

sum += Array[i];

}

avg = sum/10;

  

int highest = Array[0];

int lowest = Array[0];

for (i = 1; i < 10; i++)

{

if (Array[i] > highest) highest = Array[i];

if (Array[i] < lowest) lowest = Array[i];

}

  

for (int i=0; i<9; i++) {

for (int j=i+1; j<10; j++) {

if (Array[i] > Array[j]) {

int temp = Array[i];

Array[i] = Array[j];

Array[j] = temp;

}

}

}

  

cout<<"Largest: "<<highest<<" ";

cout<<"Smallest: "<<lowest<<" ";

cout<<"Sum: "<<sum<<" ";

cout<<"Average: "<<avg<<" ";

cout<<"Sorted Array: ";

for (i = 1; i < 10; i++) {

cout<<Array[i]<<", ";

}

  

  

  

system("pause");

return 0;

}