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
tensa zangetsu [6.8K]
3 years ago
10

You are to write a program that performs basic statistical analysis on a 500 element array of integers. Your program should incl

ude the following programmer defined functions:int* generateArray(int size){This function should dynamically create an array of 501 elements and provide random numbers to fill the array. The random numbers should range from 10 to 100. The function should return the created array to the array generated in the main program.}int findMode(int *arr, int size){This function should analyze the array to find the most occurring value in the array. You do not have to account for bi-modal occurrences, so the first modal value is enough to satisfy this function definition.}int findMedian(int *arr, int size){This function should determine the median of the set of numbers in the array. Since there are 501 elements, you should have a clean median. Do not forget that the list has to be sorted in order to properly find the median.}Of course, main is critical to the function of your program and should output the mode, median of the list. An output of the 501 element array is not necessary.
Computers and Technology
1 answer:
mrs_skeptik [129]3 years ago
3 0

Answer:

#include <iostream>  

#include <cstdlib>  

#include <ctime>  

using namespace std;

int* generateArray(int size)  

{

 int *numbers = new int[size];

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

   numbers[i] = (rand()%100) + 10;

 }

 return numbers;  

}

int findMode(int *arr, int size)  

{

 int countMode = 0;

  int mode ;

 int count;

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

    count = 1;

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

     if(arr[j] == arr[i] ){

       count++;

      }

     if(count > countMode) {

        countMode = count;

       mode = arr[i];

     }

   }

}

 return mode;

}  

int findMedian(int *arr, int size)  

{

  sort(arr,size);

  int median;

   if(size%2 == 0){

   median = (arr[int((size-1)/2)]+arr[size/2])/2;

 } else{

     median = arr[(size-1)/2];

 }

 return median;

}

void sort(int *arr, int size)

{

 int min;

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

    min = i;

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

     if(arr[j] < arr[min]){

       min = j;

     }

     if(min != i) {

       int temp = arr[i];

       arr[i] = arr[min];

       arr[min] = temp;

     }

   }

 }

}

int main()  

{

 srand(time(0));  

 int size = 501;    

 int *numbers = generateArray(size);

 cout<<"Mode : "<<findMode(numbers,size)<<endl;

 cout<<"Median : "<<findMedian(numbers,size)<<endl;  

 return 0;  

}

 

Explanation:

The C++ program is able to generate 500 integer items into the defined array and statistically analyze and provide the average and modal number in the array of integer dataset.

You might be interested in
Where can I watch all harry potter movies for free?
Ira Lisetskai [31]

Answer:

Ive streamed them before on DailyMotion

5 0
3 years ago
When a chart is selected, numerous customization options can be found on which Chart Tools tabs?
Finger [1]

When a chart is selected, numerous customization options can be found on which the Chart Tools tabs: Design and Format . Correct answer:B This tab enables you to choose predefined layouts and styles , to change the layout of chart elements manually, to change the formatting style but also to save a chart as a chart template.

3 0
3 years ago
Read 2 more answers
Write a function named remove_duplicates that takes a list (of numeric and/or string values) and returns a new list with only th
Lorico [155]

Answer:

def remove_duplicates(lst):

   no_duplicate = []

   dup = []

   for x in lst:

       if x not in no_duplicate:

           no_duplicate.append(x)

       else:

           dup.append(x)

   for y in dup:

       if y in no_duplicate:

           no_duplicate.remove(y)

   return no_duplicate

Explanation:

Create a function called remove_duplicates that takes one parameter, lst

Create two lists one for no duplicate elements and one for duplicate elements

Create for loop that iterates through the lst. If an element is reached for first time, put it to the no_duplicate. If it is reached more than once, put it to the dup.

When the first loop is done, create another for loop that iterates through the dup. If one element in no_duplicate is in the dup, that means it is a duplicate, remove that element from the no_duplicate.

When the second loop is done, return the no_duplicate

6 0
3 years ago
You are troubleshooting a computer that is in the design phase. The problem you see is that the CPU is not receiving information
IgorC [24]

Answer:

The correct option of the following question is c). control bus.

Explanation:

A control bus is a bus of the computer system which is use by the CPU(Central Processing Unit) to communicate with the devices which are contained with the computer.

CPU transmits the variety of the control signals to devices and components to transmits the control signal to the CPU by using control bus. One of the main objective of the bus is to minimize lines which are needed for the communication.

3 0
3 years ago
3. A hyperlink is important because it allows you to ___________. (1 point) click on the link to go directly to a website insert
ikadub [295]
A hyperlink is a link that can direct a person to another website when clicked. So the answer would click on the link to go directly to a website. To insert an image or sound you would use something else. And a hyperlink doesn't restrict a person to just the publisher information. I hope this helps!
3 0
3 years ago
Other questions:
  • Declare an array reference variable, week, and initialize it to an array containing the strings "mon", "tue", "wed", "thu", "fri
    15·1 answer
  • Which signal types are represented by a continuous waveform?
    10·1 answer
  • What are some reasons a person might choose to remain anonymous on the Internet?
    12·2 answers
  • How do you freeze the total cell so that it doesn't change when copied?
    6·1 answer
  • Which of the following statements is false? a. As of Java SE 8, any interface containing only one method is known as a functiona
    6·1 answer
  • Hello Answerers it would be great if you could answer this:
    12·2 answers
  • What do we do if IOC is called on the intercom ??
    14·1 answer
  • What 3 types of data can be entered in a spreadsheet
    14·1 answer
  • True or False: VLANs in cloud computing are most likely to be found on direct connections with a CSP.
    9·1 answer
  • Data becomes _____ when it is presented in a context so that it can answer a question or support decision makin
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!