Question: #Hi program crashes after it cout the input numbers - any suggestions- read in array of size - call function to sort those numbers -

#Hi program crashes after it cout the input numbers - any suggestions- read in array of size - call function to sort those numbers - reads and outputs number then crashes???? c++

#include

using namespace std;

void sortarray(int *tarray, int ); void displayarray(int *[], int); void averageshowarray(int *[], int);

int main() { int Size; int count; cout << "enter the size: " << endl; cin >> Size;

int *valptr = new int[Size];

for(count = 0; count < Size; count++) { cout << "Enter Test scores: " << endl; cin >> *(valptr + count);

} for(count = 0; count < Size; count++) { cout << *(valptr + count) << endl; }

//sort the array in order. sortarray (valptr, Size); // display the test scores and average. //displayarray(valptr, Size);

//averageshowarray(&valptr, Size);

return 0; } void sortarray(int *b, int amount) { int startscan, minindex; int *minelem;

for(startscan = 0; startscan < (amount - 1); startscan++) { minindex = startscan; *minelem = b[startscan]; for(int index = startscan + 1; index < amount; index++) { if((b[index]) < *minelem) { *minelem = b[startscan]; b[startscan] = *minelem; } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!