I am to write a program where the user is to enter a 5 or more values into a vector and it will output:
*the list of values in the same order as the user entered them
*find the min and max value of the list
*find the average value of the list
*and find the median of the list
i was able to write the code for lowest and highest value but it returns the list of values twice and each list it identifies the highest and lowest value in each list.
would it be possible to add this code to my existing code and use it for the sum formula?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
double num[5]; //5 is the number of spaces available in the variable
for (int i = 0; i < 5; i++)
{
cout << "Enter a number for space " << i + 1 << ": ";
cin >> num[i];
}
double math = 0;
for (int i = 0; i < 5; i++)
{
math = math + num[i];
}
cout << "The sum of all numbers is: " << math << endl;
double average = math / 5.0;
cout << "The average of the numbers is: " << average << endl;