1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
krok68 [10]
3 years ago
13

Write a program to read as many test scores as the user wants from the keyboard (assuming at most 50 scores). Print the scores i

n (1) original order, (2) sorted from high to low (3) the highest score, (4) the lowest score, and (5) the average of the scores. Implement the following functions using the given function prototypes: void displayArray(int array[], int size) - Displays the content of the array void selectionSort(int array[], int size) - sorts the array using the selection sort algorithm in descending order. Hint: refer to example 8-5 in the textbook. int findMax(int array[], int size) - finds and returns the highest element of the array int findMin(int array[], int size) - finds and returns the lowest element of the array double findAvg(int array[], int size) - finds and returns the average of the elements of the array
Computers and Technology
1 answer:
Oksana_A [137]3 years ago
8 0

Answer: Provided in the explanation segment

Explanation:

Below is the code to carry out this program;

/* C++ program helps prompts user to enter the size of the array. To display the array elements, sorts the data from highest to lowest, print the lowest, highest and average value. */

//main.cpp

//include header files

#include<iostream>

#include<iomanip>

using namespace std;

//function prototypes

void displayArray(int arr[], int size);

void selectionSort(int arr[], int size);

int findMax(int arr[], int size);

int findMin(int arr[], int size);

double findAvg(int arr[], int size) ;

//main function

int main()

{

  const int max=50;

  int size;

  int data[max];

  cout<<"Enter # of scores :";

  //Read size

  cin>>size;

  /*Read user data values from user*/

  for(int index=0;index<size;index++)

  {

      cout<<"Score ["<<(index+1)<<"]: ";

      cin>>data[index];

  }

  cout<<"(1) original order"<<endl;

  displayArray(data,size);

  cout<<"(2) sorted from high to low"<<endl;

  selectionSort(data,size);

  displayArray(data,size);

  cout<<"(3) Highest score : ";

  cout<<findMax(data,size)<<endl;

  cout<<"(4) Lowest score : ";

  cout<<findMin(data,size)<<endl;

  cout<<"(5) Lowest scoreAverage score : ";

  cout<<findAvg(data,size)<<endl;

  //pause program on console output

  system("pause");

  return 0;

}

 

/*Function findAvg that takes array and size and returns the average of the array.*/

double findAvg(int arr[], int size)

{

  double total=0;

  for(int index=0;index<size;index++)

  {

      total=total+arr[index];

  }

  return total/size;

}

/*Function that sorts the array from high to low order*/

void selectionSort(int arr[], int size)

{

  int n = size;

  for (int i = 0; i < n-1; i++)

  {

      int minIndex = i;

      for (int j = i+1; j < n; j++)

          if (arr[j] > arr[minIndex])

              minIndex = j;

      int temp = arr[minIndex];

      arr[minIndex] = arr[i];

      arr[i] = temp;

  }

}

/*Function that display the array values */

void displayArray(int arr[], int size)

{

  for(int index=0;index<size;index++)

  {

      cout<<setw(4)<<arr[index];

  }

  cout<<endl;

}

/*Function that finds the maximum array elements */

int findMax(int arr[], int size)

{

  int max=arr[0];

  for(int index=1;index<size;index++)

      if(arr[index]>max)

          max=arr[index];

  return max;

}

/*Function that finds the minimum array elements */

int findMin(int arr[], int size)

{

  int min=arr[0];

  for(int index=1;index<size;index++)

      if(arr[index]<min)

          min=arr[index];

  return min;

}

cheers i hope this help!!!

You might be interested in
How do you add a comment box to a multiple choice question in survey monkey?
Sunny_sXe [5.5K]

Answer:

(Hope this helps can I pls have brainlist (crown) ☺️)

Explanation:

1.Drag and drop Comment Box into your survey from the BUILDER section.

2.Enter question text.

3.Configure any additional options.

4.Click Save.

4 0
2 years ago
Jargon is:
pentagon [3]

Answer: The answer would be "B" - language that includes terms that only a select few can understand

Explanation:

3 0
2 years ago
Read 2 more answers
Sandy has an entry-level position in a graphic design company. She wants to learn more about the company and the skills she shou
Yakvenalex [24]
The answer should have been B, what was the answer?
8 0
3 years ago
Read 2 more answers
A network administrator plugs a new pc into a switch port. the led for that port changes to solid green. what statement best des
gayaneshka [121]

The port is operational and ready to transmit packets.

<h3>What is transmission mode explain?</h3>

Transmission mode refers to the mechanism of transferring of data between two. devices connected over a network. It is also called Communication Mode. These. modes direct the direction of flow of information.

<h3>What is used to transfer data packets?</h3>

A router is a networking device that forwards data packets between computer networks. Routers perform the traffic directing functions on the Internet.

To learn more about Transmission mode, refer

brainly.com/question/18590710

#SPJ4

3 0
2 years ago
Linda moderates the comments section of an online travel magazine. Which type of comments should Linda flag or delete as inappro
kvv77 [185]
Generally, an online newspaper has a code of conduct for the comments accepted. Hate speech, racism, cursing, sexual comments or bigotry is usually not allowed. She may also want to be looking for spam comments such as links or ads where someone is trying to sell something from the comment section
8 0
3 years ago
Read 2 more answers
Other questions:
  • Janet is testing the effectiveness of four different plant foods. She plants four identical seeds in four identical pots, supply
    6·2 answers
  • Bluetooth is a common wireless protocol used to make pan connections. <br> a. True <br> b. False
    7·1 answer
  • The document asks about dependents because the number can
    12·2 answers
  • ​this is another name for the wireless configuration in which a central wireless device is used to serve all wireless clients.
    13·1 answer
  • function calculate () { var s = 2; var x = 2; var y = 3; if (x &gt; 4) { s=s+ 2; } else if ( y &gt; 4) { s=s+ 4; } else { s+=3;}
    11·1 answer
  • What are the elements of a good study environment? Check all that apply.
    9·2 answers
  • A major public university graduates approximately 10,000 students per year, and its development office has decided to build a We
    10·1 answer
  • How many bits would be needed to count all of the students in class today?There are 25 in class
    15·2 answers
  • MyProgramming Lab
    5·1 answer
  • In two-dimensional arrays, the _____________ is always listed second.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!