Loop and Luhns algorithm

I'm using Luhn's algorithm for a credit card program. Part of the algorithm requires me to double the number that's two places from the right of the credit card number, and continue two palces to the left until I reach the end of the credit card number, and then add everything. But if one of the numbers I double is a double digit, for example 10, then I would have to add 1+0=1 instead of 10 to the total sum. I don't know how I would include this into the function that is in charge of this arithmetic. Any help is appreciated.

Thanks
The solution to that small problem is the same thing as solving this:

Given any integer, x, find the sum of its digits.

ie. 456 = 4 + 5 + 6
Maybe i'm overthinking it, but I don't really know how to put that into a program. I am a beginner, so I don't know much about programming.
Well, first you should read over the C++ tutorial on this website, get familiar with the language, try examples, modify those examples, and run the code to see if it works.
I have written most of the program, but sure i'll look over the tutorial. Which section would I need to read over for this specific area?
I was assuming when you said "I don't really know how to put that into a program" that you don't understand the concepts of variable and data types and the various operations you can do with them like addition, subtraction, and so forth.

But since you've written most of the program, you know the basics.

There's isn't any section that would specifically help with the problem that I've given you.

However, you should look into the modulus operator (%) which can help you.
Topic archived. No new replies allowed.