Lab 1 Direction: Submit the typed source code Class Statistics csiste of the fol
ID: 3590940 • Letter: L
Question
Lab 1 Direction: Submit the typed source code Class Statistics csiste of the following ndices Yoa will have to complete the following eode Sert O Parameter(s):float Return data Description sorto the clements of data whoue siee to siac in cedin orde IL. Maximun Parameter(s): oat: data Return: Description: returns the largest element of data whose size is size. float Name: Mininun O Parameter(o):Bont: data Return Description: returns the smallest element of data whose size is size. int: ize float IV. Name: Parameter(s): Return: Range ) float : data int : size float Description: returns the distance between the smallest and largest elements of size is sizeExplanation / Answer
Here is the code for the first 4 functions:
void Sort(float data[], int size)
{
for(int i = 0; i < size-1; i++)
for(int j = 0; j < size-i-1; j++)
if(data[j] > data[j+1])
{
float temp = data[j];
data[j] = data[j+1];
data[j+1] = temp;
}
}
float Maximum(float data[], int size)
{
float max = data[0];
for(int i = 1; i < size; i++)
if(data[i] > max)
max = data[i];
return max;
}
float Minimum(float data[], int size)
{
float min = data[0];
for(int i = 1; i < size; i++)
if(data[i] < min)
min = data[i];
return min;
}
float Range(float data[], int size)
{
return Maximum(data, size) - Minimum(data, size);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.