Requirements for the program:
Create an array of 30 random double values in the range of 50-100. Name the Array Grades. Fill the array with grades from x assignments. Display the values of the array. Find the average of the values. Search the array for the highest value. Search the array for the lowest value.
*Sort the grades from lowest to highest
PROBLEM:
I am getting an error when I run my program. Any suggestions on how I should fix it would be greatly appreciated..
Also not sure how to sort the grades from lowest to highest...
Here is what I have done so far...
//////////////////////////////////////////
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
double rand50_100()
{
double value = 50 + (rand() % 51);
}
void loadValues(double grades[],int len)
{
int i;
When posting code, please use code tags. While editing your post, highlight the code and click the <> button to the right of the edit window.
It's helpful to compile with warnings enabled. When I compiled your code with warnings enabled it found that rand50_100() doesn't return a value. It should be:
You could do it with one line (return 50 + (rand() % 51);) but it's a good habit to put the return value in a variable first so you can see it with a debugger if necessary.
double grades[x]; //initializing the array.
This is actually illegal C++, although it's supported by some compilers as an extension. It's better to use vectors instead if you've learned about them.
Also not sure how to sort the grades from lowest to highest...