I am trying to understand the second to last digit thing, i think i have been coding wrong the whole time. take this example 45002136581 in the walk through the guy says we take 5 0 2 1 5 1. while i was searching for the meaning of this turned out second to last digit means to skip the first digit and take the second in this example it would be something like 5 0 1 6 8...... so i am so confused can you please enlighten me. i hope you understand what i am trying to explain. so this is my first point.

second thing is i was able to find the last digit basically we use the mudo % to find the remainder. But what function should i use to find second to last digit, i was thinking of dividing the card number by 10 for the first time after by 100 after by 1000 till i check all the digits of the card, please correct me if i am wrong.

  • CSsucks yes it is clear now but i thought we should start from the beginning as i mentioned above, is it going to affect the outcome if i did?, because that is what i understood from the walk through? Apr 28, 2020 at 3:22

1 Answer 1


Second to last digit means the second digit starting from the end of the number. For your example - 45002136581: The digits will be 8, 6, 1, 0, 5 (or 5, 0, 1, 6, 8 in correct order).

I would suggest to use cardnumber%10 operator and cardnumber/10 iteratively to get the required outcome.

I hope it is clear now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .