# Credit pS1: how to store the seperate digits and store them

Thank you for the answers. I think that I made some steps. The problem now is that I can't store the seperated digits. It only stores the last one in "remain". My other challenge is that seperating the digits above 9 gives the result "0" but i think that is related to the "remain" problem. This is what i have so far.

``````//Get creditcard number
do
{
credit = get_long("Number: ");
}
while (credit < 0);

//Select every other digit starting with number'second to last digit.
tempa = credit;
tempa = tempa /10;
while (tempa > 0)
{
remain = tempa % 10;
// test outcome of remain
printf("%li\n", remain);
sumc = sumc + remain;
tempa = tempa /100;
}
//test outcome of suma
{
printf("sumc: %li\n", sumc);
}
// Multiply every other digit with 2
remain = remain *2;
//test for multiply
{
printf("Remain: %li\n", remain);
}
// split the digits above 9 in two seperated digits
for (remain = 0; remain > 9; remain++)
if
{
new_sum = remain % 10;
r = remain + new_sum;
new_sum = new_sum / 10;
}
else // ????
//test outcome of r
{
printf("r: %li\n", r);
}
// print the sum of the products
outcome = sumc + r;
{
printf("Outcome: %li\n", outcome);
}
``````

There are two ways to do it: the easier way would be to simply store a variable, say `total`, and keep adding the digits to it in the loop. The other (and more complicated) way would be to make an array of digits and keep filling it in as you go, which is harder because you do not know how many digits there will be. You aren't introduced to arrays until next week in the course, so the best way is to simply keep adding the digits as you go, and then outside the loop, multiply that variable by two.