Hey guys,
I have been reading the forum for a while, but I couldn't find anything that could help to figure out my current assignment. Its a very simple program, but somehow just doesn't work for me. I'm a beginner and I hope that somebody can explain what am I doing wrong.
The program should as the user how many values she would like to enter (max 50). Then the program should ask to enter the values.
These values should be stored in double array and then printed out in descending order, using bubble sort.
I have got this code so far... Please advise if you can on what can I do to make it work.
I can only use very basic codding as well..
#include <iostream>
using namespace std;
int main()
{
double nums[50];
int size, a, b, t;
cout << "How many values would you like to enter?\n";
cin >> size;
cout << "Please enter the values:\n";
cin >> nums[size];
// bubble sort code
for (a=1; a<size; a++)
for (b=size-1; b>=a; b--) {
if(nums[b-1] < nums[b]) {
t=nums[b-1];
nums[b-1] = nums[b];
nums[b] = t;
}
}
cout << "Sorted array is:\n";
cout << nums[size] << "\n";
return 0;
}