I assume anyone looking at this question knows the assignment but to recap I need to write a program that will identify different CC#s—AMEX, MC, VISA, or Invalid. Since all these CCs range from 13-16 digits...

I want to verify the input parameters for the initial credit card number such that anything less than 13 digits or more than 16 digits will immediately return an "Invalid" answer OR reprompt the user for a new input—either one is fine since they'll be different lines of code. Because I'm new to programming, I'm not sure how to identify range of the string of digits. I figure it has to do with an array but I'm not sure how that will look in the code editor.

1 Answer 1


You will need to 10 your number until there are no more digits, adding 1 to a variable each time to find out how many numbers are in your long long.

do  //extract the even numbers and add them up
    numEven = mash % 10;
    mash = mash / 100;
    even = even + numEven;
  • Thanks again for your feedback. This particular setup may or may not work for my purposes but I'm afraid none of that has been covered in the course up to the point of the assignment. And it is totally outside the scope of what I've learned thus far. I've seen several solutions to the assignment that rely on significant chunks of code that were never taught in the class, nor were they provided in the lectures, walkthroughs, or mini-lessons. Can you explain your code and how it would work given my initial question? Thanks. Sep 8, 2018 at 20:38
  • This is a "more comfortable" problem that assumes you have prior experience. Having to use language features that you haven't been taught yet is expected.
    – curiouskiwi
    Sep 9, 2018 at 3:53

You must log in to answer this question.

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