user input to an integer array

Hi,

I want to set a user-define integer array for the following calculation:

e.g.
ISBN: 780225321-7 (7*1+8*2+0*3+2*4+2*5+5*6+3*7+2*8+1*9)=117

ISBN: 020170434-X (0*1+2*2+0*3+1*4+7*5+0*6+4*7+3*8+4*9)=131

the array should be of 9 digits

error message:
no match for 'operator>>' in 'std::cin >> ISBN'


my code is:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

#include <iostream>;
using namespace std;

int main()
{   double ISBN[9];
    int sum=0, subsum=0; // initialize
    char c; // save the check digit
    
    cout << "Enter 9-digit book number: "<<endl;
    cin >> ISBN;
    
        for (int i = 0; i < 8; ++i)
        {
            sum = sum + ISBN [i] * (i + 1);
            }
    
    cout << sum << endl;
}


may anyone please help?
Last edited on
If you want to read a number for every element of an array, use a loop. Though then you'd have to enter the digits separated with spaces. The better way would be to read a string (array of 10 chars. 9+1 for the \0). Then convert them from ASCII symbols to their integer values (subtract '0' from each of them).
excuse me I am a newbie to C++. having only learnt a couple of lectures i dont know what do you mean by the '0'. may you explain it a bit further?
Topic archived. No new replies allowed.