do-while array

I'm trying to create a do-while statement, which is not my strongest suit. I'm trying to figure out how to get these two arrays to display properly but I'm not sure what I'm supposed to do. I don't have too much of the code down but I would love some pointers. Am I even heading in the right direction?

int main()
int points[5] = {62, 75, 100, 83, 85};
char grades[5] = {'D', 'C', 'A', 'B', 'B'};
int testScore = 0;
cout << "Enter a test score: ";
cin >> testScore;

while (testScore

return 0;
} //end of main function


  • testScore should check for a "sentinel" value; for example, if you prompt your user to enter data or -1 to quit, then testScore should test against -1.

    do {
    cout << "Enter a test score (-1) to quit: ";
    cin >> testScore;

    // some something with testScore if it's not -1

    } while(testScore != -1);

    As far as the two arrays go, it's not clear what you're trying to accomplish in terms of how they relate to testScore if at all.

    You *can eliminate* system("pause") by using
    while(cin.get() != '
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion