Need help with a Luhn Algorithm assignment

This is what I have so far. Here's what the assignment is about: Let someone enter 1-13 digits (it can be segmented or whole and it's their choice when to stop). Then, create a checksum using Luhn's Algorithm.

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
  #include<iostream>
using namespace std;

int main ()
{
	int pause;
	const int length = 13;
	float PIN[length];
	PIN[length-1]=0;

	cout << "Please enter any PIN you desire. Enter 'q' to finish. You can enter up to 13 digits." << endl;

	for (int i=0;i<13;i++)
	{
		cin >> PIN[i];
		if (PIN[i] == 'q')
		{
			break;
		}
	}

	cout << PIN;
	cin >> pause;

	return 0;
}


The problem here is that I'm not sure on how to stop the digits (so that the person has a choice of choosing how many digits he wants). I would like some help on that (I'm not sure if you have to store it in an array like I did; maybe I'm completely wrong?). I would also appreciate some help on how to extract the number from the array (if I need one) since I have a general idea, but I'm not quite sure. Any help is appreciated. Thanks!
Help please?
you can not use the index of the array as if it were a variable. at least in this manner.
groped to block the inclusion of the elements of the array, is nothing more than an attempt to transform the array index by constant variable. In fact, fixing your code (because it does not work), however in the end, if you try to do a print screen, once the length of the stubble, for items exceeding your pin, random numbers are generated.
But how would you extract the numbers?
For instance:

cin >> PIN

^
How would you extract separate digits from that PIN?
OK, I'm here with an update. This is what I have 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
#include<iostream>
using namespace std;
#include<string>

int main ()
{
	int pause;
	string input;
	int pin[13];
	cout << "Enter a PIN number please. No more than 13 digits." << endl;
	cin >> input;
	int length = input.length();
	for (int i = 0; i <= length-1 ; i++)
       {
               pin[i] =  static_cast<int>(input[i]) - 48;
               cout << pin[i] << endl;
       }

	for (int k = length-1;k>=input[0];k--)
	{
		

	cin >> pause;
	return 0;
}


Now my problem is how do I transfer the numbers from one for-loop to another since everything I do in one for-loop is invalidated in the other. I need the digits to calculate the checksum.
Any help on transferring data between for-loops?
Topic archived. No new replies allowed.