Can't figure out why my code won't retrieve more than the first input, in a loop.
This is what I have so far:
Code:
#include <iostream>
#include <string>
using namespace std;
const int SENTINEL = -999;
int main()
{
int studentNumber[100];
string studentLastName[100];
double studentGPA[100];
int stuNum;
string stuLName;
double stuGPA, sum, average;
cout << "Please enter a student number, -999 to end:";
cin >> stuNum;
for(int counter = 99; counter >= 0; counter--)
{
while (stuNum != -999)
{
cout << "Enter last name: ";
cin >> stuLName;
cout << "Enter Student GPA: ";
cin >> stuGPA;
studentNumber[counter] = stuNum;
studentLastName[counter] = stuLName;
studentGPA[counter] = stuGPA;
counter++;
cout << "Enter Student number, -999 to end: " ;
cin >> stuNum;
}
cout << "The reverse is:";
cout << studentNumber[0] << " ";
cout << studentLastName[0] << " " << studentGPA[0];
cin >> stuGPA;
}
cout << endl;
return 0;
}