Need some guidence

Ok so I am in need of some help i have this part of my code i am working to try to get it to where my array will take in a negative value to stop the loop. also is there any way i can get it to keep accepting values til the negative is inputted?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int ARRAY_SIZE = 25;
void Obtain (double grade[], int ARRAY_SIZE)
{
    int  n,j = 0;

    for (n = 0; n < ARRAY_SIZE;  n++)
    {

            cout << "Enter a Grade : ";
            cin >>  grade[n];

                if(!cin)
                {
                    cin.clear();
                    cin.ignore(500, '\n');
                    cout << "You entered in a wrong number try again." << endl;
                }

                if (grade < 0 )
                    break;
    counter++;
    }

}
Last edited on
Change if (grade < 0 ) -> if (grade[n] < 0 )


Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/
thanks for that and sorry thought i had the in there must have been deleted when i put the code in the text window. is there a way to make it so that my user can enter in any amount of input to into the array?
is there a way to make it so that my user can enter in any amount of input to into the array?

Use a std::vector.
Topic archived. No new replies allowed.