Improve credit.c
elisabethirgens opened this issue · comments
Elisabeth Irgens commented
This problem is from week 1, before we have gotten to for example arrays or functions, so I wanted to solve it using only the concepts that have been introduced so far in the program: data types, conditional statements and loops.
Even with these limitations, I think there are more potential improvements:
- Can the checksum code be simplified with fewer variables? More resursive somehow?
- Could the two
while
loops be combined to handle alternating digits? - Would a
switch
at the end be more readable than this weird nesting ofif else
?
Might also be interesting to see which other refactoring comes naturally after more weeks of programming with C.