Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

INSTRUCTOR SUPPLIED DRIVER FILE: #define INSTRUCTOR_FILE #ifdef INSTRUCTOR_FILE #include #include #include #include using namespace std; #define Elements(A) (sizeof(A) / sizeof(*(A))) float *SortValues(float *first, size_t elements);

image text in transcribed

INSTRUCTOR SUPPLIED DRIVER FILE:

#define INSTRUCTOR_FILE #ifdef INSTRUCTOR_FILE

#include #include #include #include using namespace std;

#define Elements(A) (sizeof(A) / sizeof(*(A)))

float *SortValues(float *first, size_t elements); float *GetValues(float *first, size_t elements); static bool DisplayValues(float *first, size_t elements);

int main() { const size_t lengths[] = { 12, 9, 7 };

for (size_t testIx = 0; testIx

// Allocate the array. float *arr = new (nothrow) float[elements]; if (!arr) { cerr

const size_t halfway = elements / 2;

// Initialize array. for (size_t ix = 0; ix

pRtn = GetValues(arr + 1, elements - 2); if (pRtn != arr + 1) cerr

if (arr[0] > FLT_MIN || arr[elements - 1]

// Test that array values have changed. This assumes FLT_MIN and FLT_MAX // are not input values. for (size_t ix = 1; ix

pRtn = SortValues(arr + 1, elements - 2); if (pRtn != arr + 1) cerr

if (arr[0] > FLT_MIN || arr[elements - 1]

DisplayValues(arr + 1, elements - 2);

delete[] arr; }

return EXIT_SUCCESS; }

bool DisplayValues(float *first, size_t elements) { bool badSortOrder = false, equalValueElements = true, badValue = false; float previousVal = *first, firstVal = *first;

// For each element for (float *p = first, *end = &first[elements]; p

if (*p == FLT_MIN || *p == FLT_MAX) badValue = true;

if (p != first) // if not at the first element... { if (previousVal

if (badSortOrder && badValue) cerr C2A6E2 (4 points-C++ Program) Exclude any existing source code files that may already be in your IDE project and add two new ones, naming them C2A6E2_Getvalues.cpp and C2A6E2_Sortvalues.cpp. Also add instructor-supplied source code file C2A6E2_main-Driver.cpp. Do not write a main function main already exists in the instructor-supplied file and it will use the code you write. Fie C2A6E2_Getvalues.cpp must contain a function named Getvalues. Getvalues syntax float "Getvalues (float first, size_t elements); Parameters: first -a pointer to the first element of an amay of floats elements - the number of elements in that array Synopsis: Prompts the user to input elements whitespace-separated floating point values, which it then reads with cin and stores into the successive elements of the array in first starting with elemento Return: a pointer to the first element of the amay File C2A6E2_Sortvalues.cpp must contain a function named Sortvalues. Sortvalues syntax float *Sortvalues (float first, size_t elements); Parameters: first-a pointer to the first element of an amay of floats elements - the number of elements in that array Synopsis: Sorts the amay in first in descending order using the "bubble sort" algorithm Return: a pointer to the first element of the sorted array Sortvalues must not call any functions. GetValues must not call any functions other than operator>> and operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago