Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ use Sort function: void sort(double x[], int n) { // Declare objects. int m; double hold; // Implement selection sort algorithm for (int

in C++

use Sort function:

void sort(double x[], int n)

{

// Declare objects.

int m;

double hold;

// Implement selection sort algorithm

for (int k = 0; k <= n-2; ++k)

{

// Find position of smallest value in

// array beginning at k

m=k;

for (int j = k + 1; j <= n - 1; ++j)

{

if (x[j] < x[m])

m = j;

}

// Exchange smallest value w/value at k

hold = x[m];

x[m] = x[k];

x[k] = hold;

}

// void return

return;

}

Write a main function that create an array of integers called grades with contents {100, 95, 87, 92, 79}. Then it prompts the user to enter a number and searches the array for that number. If the number is in the array, it prints out to the user the position it found it at. If the number is not in the array, it prints out that it did not find it.

For example, if the user enters 7, the program will print out "Sorry, 7 was not found". If the user enters 95, the program will print out "Success. Found 95 at position 1 of the array".

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago