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
Elizabeth has an assignment to complete. in her internet search, she got 5,006,321 hits. to narrow the search, she would convert
ivolga24 [154]
In order to narrow the search and get more precise and more efficient Internet research, Elizabeth should use unique and specific terms, should not use common words, she could use some search engines also (Exploratium, Teoma,...) ..., use different search engines search engines, like Yahoo!, Bing, Startpage, or Lycos.
6 0
2 years ago
Read 2 more answers
You often travel away from the office. While traveling, you would like to use a modem on your laptop computer to connect directl
34kurt

Answer:

The answer is "Remote access "

Explanation:

The capacity to access another computer or network that you do not have. Remote computer access provides an employee with remote access to the desktop and file. This assists an employee, for example, who works at home efficiently.

Remote users access documents or other resources on any network-connected device or server, enhancing organizational efficiency and increase there are to cooperate more interact with peers nation.

6 0
2 years ago
Instructions:Select the correct answer from each drop-down menu.
mario62 [17]

when using a dark background for presentations you should use bright colors to contrast with it


this makes the informations much easier to see and read for example white text on black background

6 0
2 years ago
What is sytem software?
schepotkina [342]

Answer:

system software is the set of computer programs that controls and manage the operations of computer hardware.

7 0
1 year ago
Explain in detail why intel 8086 segments are 64 KB in size?
gtnhenbr [62]

Answer:

Explanation:

phân đoạn bộ nhớ x86 đề cập đến việc thực hiện phân đoạn bộ nhớ trong Intel x86 máy vi tính bản hướng dẫn kiến ​​trúc. Phân đoạn đã được giới thiệu trên Intel 8086 vào năm 1978 như một cách cho phép các chương trình có địa chỉ hơn 64 KB (65,536byte) của bộ nhớ. Các Intel 80286 đã giới thiệu phiên bản thứ hai của phân đoạn vào năm 1982 bổ sung hỗ trợ cho bộ nhớ ảo và bảo vệ bộ nhớ. Tại thời điểm này, mô hình ban đầu đã được đổi tên chế độ thựcvà phiên bản mới được đặt tên chế độ bảo vệ. Các x86-64 kiến trúc, được giới thiệu vào năm 2003, phần lớn đã bỏ hỗ trợ phân đoạn ở chế độ 64-bit.

Ở cả chế độ thực và chế độ được bảo vệ, hệ thống sử dụng 16-bit đăng ký phân đoạn để lấy địa chỉ bộ nhớ thực. Ở chế độ thực, các thanh ghi CS, DS, SS và ES trỏ đến chương trình đang được sử dụng đoạn mã (CS), hiện tại phân đoạn dữ liệu (DS), hiện tại phân đoạn ngăn xếp (SS) và một thêm phân đoạn do người lập trình xác định (ES). Các Intel 80386, được giới thiệu vào năm 1985, bổ sung thêm hai thanh ghi phân đoạn, FS và GS, không có mục đích sử dụng cụ thể nào được xác định bởi phần cứng. Cách thức sử dụng các thanh ghi phân đoạn khác nhau giữa hai chế độ.[1]

Việc lựa chọn phân đoạn thường được bộ xử lý mặc định theo chức năng đang được thực thi. Các hướng dẫn luôn được tìm nạp từ đoạn mã. Mọi lần đẩy hoặc bật ngăn xếp hoặc bất kỳ tham chiếu dữ liệu nào tham chiếu đến ngăn xếp đều sử dụng phân đoạn ngăn xếp. Tất cả các tham chiếu khác đến dữ liệu đều sử dụng phân đoạn dữ liệu. Phân đoạn bổ sung là đích mặc định cho các hoạt động chuỗi (ví dụ: MOVS hoặc CMPS). FS và GS không có mục đích sử dụng do phần cứng chỉ định. Định dạng hướng dẫn cho phép một tùy chọn tiền tố phân đoạn byte có thể được sử dụng để ghi đè phân đoạn mặc định cho các hướng dẫn đã chọn nếu muốn

8 0
2 years ago
Other questions:
  • Owning provides _________ flexibility but can lead to _________ costs in the long-term.
    7·2 answers
  • Hurry plz
    8·1 answer
  • Write a program in java that reads each line in a file, reverses its characters, and writes the resulting line to another file
    15·1 answer
  •  How does critically analyzing technology add value to interactions with people in personal and professional contexts?
    7·2 answers
  • Rewrite each condition below in valid Java syntax (give a boolean expression): a. x &gt; y &gt; z b. x and y are both less than
    7·1 answer
  • Why is yo utu be down?<br> (You restrict talking about yo utu be, really)
    11·2 answers
  • I need the answer to life. I cant live without my POGCHAMPS!
    11·2 answers
  • Discuss the term internal control​
    12·1 answer
  • a data analyst is working with a spreadsheet that has very long text strings. rather than counting the characters themselves to
    9·1 answer
  • the 4gl languages that enable nonprogrammers to use certain easily understood commands to search and generate reports from a dat
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!