Asking a user to input scores + array and bool usage

I'm working on a C++ project right now (will post instructions on the project if and when necessary) and I'm stumped at this point. I've not a clue of what to do next (I am not finished with the code). Here is my code so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <cctype>
using namespace std;

bool digits (char []);
bool negative (char []);
bool numbers (int);

int main()
{
    char input[15], numberofscores[15];
    int numbscores, currnumbscores=0, scores=0;
    
    cout << "How many scores are you going to enter? ";
    cin >> numberofscores;
    while((negative(numberofscores)==1)||(digits(numberofscores)== 1))
    {
                                        cout << "You have entered an invalid number of scores" << endl;
                                        cout << "How many scores are you going to enter? ";
                                        cin >> numberofscores;
    }
    numbscores = atoi(numberofscores);
    int scoresarray[numbscores], sum=0;
    while(currnumbscores < numbscores)
    {
                         cout << "Enter score " << currnumbscores+1 << ": ";
                         cin >> input;
                         bool isnegative = negative(input);
    }
    return 0;

}

1
2
3
 char input[15], numberofscores[15];
//...
numbscores = atoi(numberofscores);

Why do you take numberofscores input as a string and convert it to integer a few lines down? Take an integer instead.
1
2
3
4
5
6
while(currnumbscores < numbscores)
    {
                         cout << "Enter score " << currnumbscores+1 << ": ";
                         cin >> input;
                         bool isnegative = negative(input);
    }

In while loop, you have to increment the currnumbscores. I'd use a for loop, since you know exactly how many elements you have in the array.
bool isnegative = negative(input);
I suppose negative() checks if the value is less than zero. The result is stored to isnegative var, but you're not doing anything with it.

Nhf. but to me, it seems this isn't your code.
Topic archived. No new replies allowed.