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

this is my homework and I dont even know how to start the program can someone pl

ID: 3638422 • Letter: T

Question

this is my homework and I dont even know how to start the program can someone please help me.

Thank you very much for your time

Write a program to sort an array of 10 numerical values from smallest to largest.
–Program should have a user-defined sort() function that
•Takes an array and its size as input parameters
•Sorts the array from smallest to largest
–Program can optionally use a swap function if needed
–You are free to come up with your own algorithm for sorting or use the Bubble Sort

This is the pseudo code professor give but I do not know how to start


#include "stdafx.h"
#include <iostream>
using namespace std;


/*
Description: swaps values of two cells in the array

Parameters:
dataArray: array of double values
i: array index for the first value
j: array index for the second value

Return Value: None
*/
void swap(double dataArray[], int i, int j)
{
// copy value at cell i to a new variable
// copy value at cell j to cell i
// copy value from new variable to cell j
}

/*
Description: sorts the array values from lowest to highest

Parameters:
dataArray: array of double values
arraySize: number of values in the array

Return Value: None
*/
void sort(double dataArray[], int arraySize)
{
for (int i = 0; i < arraySize; i++)
{
for (int j = i + 1; j < arraySize; j++)
{
// if array value at j is less then array value at i then
// swap the values at two locations using the swap function
// declared above
}
}
}

/*
Description: Main entry-point. Asks users to enter 10 values.
Sorts the values and displays results

Parameters: None
Return Value: 0
*/
int main()
{
char key;

do
{
const int ARRAY_SIZE = 10;
double dataArray[ARRAY_SIZE];

cout << "Please Enter 10 numbers to sort: " << endl;

for (int i = 0; i < ARRAY_SIZE; i++)
{
cin >> dataArray[i];
}

sort(dataArray, ARRAY_SIZE);

cout << "-- Sorted Array --" << endl;
for (int i = 0; i < ARRAY_SIZE; i++)
{
cout << dataArray[i] << endl;
}

cout << "Press any key to continue (or Q to quit)" << endl;
cin >> key;
} while (key != 'Q');

return 0;
}

Explanation / Answer

#include "stdafx.h" #include using namespace std; /* Description: swaps values of two cells in the array Parameters: dataArray: array of double values i: array index for the first value j: array index for the second value Return Value: None */ void swap(double dataArray[], int i, int j) { int temp=dataArray[i]; dataArray[i]=dataArray[j]; dataArray[j]=temp; // copy value at cell i to a new variable // copy value at cell j to cell i // copy value from new variable to cell j } /* Description: sorts the array values from lowest to highest Parameters: dataArray: array of double values arraySize: number of values in the array Return Value: None */ void sort(double dataArray[], int arraySize) { for (int i = 0; i