I think you may have a problem when iterating i up to a large cardNum because cardNum is long long which can hold huge numbers but int i is just an int relatively small.
To solve this problem try holding the cardNum as a string extracting each digit from it and parsing them into an int. You can then multiply and add them up without dealing with representing huge numbers.