I am trying to write a program that will dynamically allocate an array based on how many students are taking a survey. Our instructor is only allowing us to use pointer notation for the arrays (with the exception of the "new" and "delete" commands).
Here is what I have so far:
#include <iostream>
using namespace std;
void selection_sort(int *, int);
int main()
{
int *movieData;
int SIZE;
cout << "This program asks for the number of students who participated\n"
<< "in a movie survey, and then asks for the number of movies each\n"
<< "student saw in a given month. The program will then compute\n"
<< "the mean, median, and mode of the data entered.\n\n";
cout << "Please enter how many students participated in the survey: ";
cin >> SIZE;
while(SIZE < 0)
{
cout << "Negative numbers are not allowed.\n"
<< "Please enter how many students participated in the survey: ";
cin >> SIZE;
}
movieData = new int[SIZE];
for(int x = 0; x < SIZE; x++)
{
cout << "Please enter number of movies seen by student "
<< x + 1 << ": ";
cin >> *(movieData + x);
while(*(movieData + x) < 0)
{
cout << "Negative numbers are not allowed.\n";
cout << "Please enter number of movies seen by student "
<< x + 1 << ": ";
cin >> *(movieData + x);
}
}
for(int x = 0; x < SIZE; x++)
{
cout << *(movieData + x) << " ";
}
cout << endl;
selection_sort(movieData, SIZE);
for(int x = 0; x < SIZE; x++)
{
cout << *(movieData + x) << " ";
}
cout << endl;
system("PAUSE");
return 0;
}
void selection_sort(int *movieData[], int SIZE)
{
int startScan, minIndex;
int *minElem;