#include <iostream>
#include <string>
usingnamespace std;
void inputArray(double*);
//void calculate();
//void display();
int main() {
double inputGrades[30];
double *grades;
grades = inputGrades;
inputArray(grades);
system ("pasue");
return 0;
}
void inputArray(double *grades) {
int index = 0;
cout << "Enter a Grade (or -1 to quit): ";
cin >> grades[index];
while (grades[index] != -1); {
index++;
cout << "Enter a Grade (or -1 to quit): " << endl;
cin >> grades[index];
}
}
void calculate() {
}
void display() {
}
For the assignment, all parameters have to be pointers, and I have to use a sentinel loop to read in 30 values into an array. However, when I enter a normal integer into the cin portion, it doesnt loop. It doesnt do anything.
You shouldn't have a semicolon after your while loop on line 29. With the semicolon, your code is equivalent to:
1 2 3 4 5 6
while (grades[index] != -1) {
// do nothing
}; // <-- the semicolon you have on line 29
index++;
cout << "Enter a Grade (or -1 to quit): " << endl;
cin >> grades[index];
Now I am having an issue with the program closing after the -1. I dont want it to terminate. I was going to add the other functions to create a histogram and display all the grades.