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!!!