SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 313 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 02 Jan 2018 My Price 10.00

function to sort the entered integers from lowest

How can i create a sort function to sort the entered integers from lowest to biggest before calculating the mean, median, and the rest of the functions. sort function is what i need . email attachment on what I need to do for the sortingIMG_0657.PNG

 

 

#include <iostream>

#include <stdlib.h>

#define SIZE 10

using namespace std;

// SIGNATURES of all the required Functions

void display(int []);

double mean(int []);

int median(int []);

void lessThanFive(int []);

int minimum(int []);

int sum(int []);

// MAIN FUNCTION

int main()

{

int arr[SIZE]; // Array to store the integers

double avrg; // To store the average returned by the mean() Function

int mid = 0; // To store the median returned by the median() Function

int mini; // To store the minimum value of the array returned by the minimum() Function

int total =0;

// Read the values for the array

cout << "nEnter 10 values in the array (one by one):" << endl;

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

cin >> arr[i];

}

// Function call to display()

display(arr);

// Function call to mean()

avrg = mean(arr);

cout << "nAverage of the 10 values of the array is: " <<avrg;

// Function call to median()

mid = median(arr);

cout << "nMiddle Value of the array is: " << mid;

//Function call to lessThanFive()

lessThanFive(arr);

// Function call to minimum()

mini = minimum(arr);

cout << "nMinimum value in the array is: " << mini << endl;

// Function call to sum()

total = sum(arr);

cout << "nSum of the 10 digits in the array: " << total;

cout << endl;

return 0;

}

 

// Function display(): To display all the integers in the array

void display(int arr[]){

cout << "nIntegers in the array: " << endl;

// Loop through every index of the array and print it on the screen

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

cout << arr[i] << " " ;

}

cout << endl;

}

// Function mean(): To return the average of the 10 values in the array

double mean(int arr[]){

int sum = 0;

double average = 0.0; // To store the average of Integers

// Loop through all the values and add them together

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

sum = sum + arr[i];

}

average = (double)sum / SIZE ;

return (average); // Returning the Average of the values

}

// Function median(): To return the middle value of the array

int median(int arr[]){

int average = 0;

int middle1, middle2; // To store the middle positions

middle1 = SIZE / 2;

middle2 = (SIZE / 2) - 1;

if((SIZE % 2) == 0) // If the size of the array is even

{

average = (arr[middle1]+arr[middle2]) / 2;

cout<<"nnThe no. of values is even! Getting Average of the two middle values...";

return average;

}

else{

return arr[middle1];

}

}

// Function lessThanFive(): To display values in the array which are less than 5

void lessThanFive(int arr[]){

int count = 0;

cout<<"nnThese are the values in the array which are less than 5: " << endl;

// Loop through all the values and check if they are less than five

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

if (arr[i] < 5){

cout << arr[i] << " ";

count ++;

}

}

if(count == 0)

cout << "There is no such value!" << endl;

cout << endl;

}

// Function minimum(): To return the minimum value in the array

int minimum(int arr[]){

int minval = arr[0]; // set the default minimum value to the first value

// Loop through all the values and check if they are less than the current minimum value

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

if(arr[i] < minval) // If the value is less, set minval = value in the array

minval = arr[i];

}

return minval; // Returning the minimum value

}

// Function sum(): To return the sum of the 10 digits in the array

int sum(int arr[]){

int totalval = 0; // Set default sum equal to 0;

// Loop through each value in the array and add it to the previous sum

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

totalval = totalval + arr[i];

}

return totalval; // Return the sum

}

 

Attachments:

Answers

(5)
Status NEW Posted 02 Jan 2018 06:01 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)