hi Could someone please help me urgently with my computer programming project. This is the assignment:

Create a program in which a user is asked for how many values (s)he wants to enter (maximum 50), then:

Asks for the values and stores them into an array of double.
Sorts the values in ascending order according to the following algorithm, where size is the number of doubles to be sorted:

        for i=0..size-2
            check all the values between position i and size-1 to find the smallest one
            swap the smallest value and the one in position i

Prints the sorted array to the console.

Me and my friend have already come up with this code:

#include <iostream>

using namespace std;

int main() {

int size;
    do {
    cout << "hello user, enter the size of your array: ";
    cin >> size;
    } while (size > 50 || size < 0);

    double *arr = new double[size];
    cout << "now fill the array with " << size << " values: " << endl;

    for (int i = 0; i < size; i++) {
    cin >> arr[i];
    }
    cout << "the content of the array is: " << endl;

    for (int i = 0; i < size; i++)
    cout << arr[i] << " ";
    cout << endl;
    delete [] arr;
    return 0;
    }

but its not really working and its not sorting out the code! Im absolutely awful at computer programming so if someone cud help me out id be very very grateful!!!

Onlineshade commented: Post the code as [code]....[code]. -1

another friend has this code which we think is better for the question : but it still doesnt sort out the code from ascending etc

#include <iostream>

using namespace std;

int main()
{
int size;
double i;

do {
cout << "So, please enter the size of your array with the maximum being 50: ";
cin >> size;
} while (size > 50 || size < 0);

double *arr = new double;

cout << "\nNow fill your array by entering " << size << " values (press enter after each value): " << endl;

for (int i=0; i < size; i++) {
cin >> arr;
}

/*
Selection sort algorithm
*/
for (int i = 0; i < size - 1; i++) {
// Find the index (min) of the smallest item
// Swap arr[min] with arr
}

cout << "\nYou entered: " << endl;

for (int i=0; i < size; i++)
cout << arr << " ";

cout << endl;

delete [] arr;
}

Thats farrrr to complicated for me! I didnt understand one thing you said!! I'm a complete beginner at programming!!!

Thats farrrr to complicated for me! I didnt understand one thing you said!! I'm a complete beginner at programming!!!

start with this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.