i have to create a program in which a user is asked for:
How many values (s)he wants to enter (maximum 50);
Asks for the values and stores them into an array of double.
Sorts the values in descending order.
Prints the sorted array to the console.
this is what ive got so far:
#include <iostream>
#include <cstdlib>
using namespace std;
int main ()
{
int quantity;
cout << "Enter the amount of values you want to sort (max 50): ";
cin >> quantity;
do
{
cout << "That is too many values. Please enter a max of 50!: ";
cin >> quantity;
}
while (quantity >50);
{
cout << "Enter " << quantity << " values: ";
double values[quantity];
cin >> values[quantity];
cout << values;
}
return 0;
}
i know its not finished yet. so far i have done the initial input and now am trying to get the array to work.
My problem is the array 'values'. Every time i run this program i can enter the amount of values normally but when i input the values it just gives me out a load of jibberish. i.e 0x7fff5fbff700 or something similar. could someone tell me why this happens and how to fix it.
thanks