Why my answer is wrong

my answer

i try to create a int called sum and add the first digit and last digit to sum and then cout them.
last digit is using the (% 10) to find
first digit is constantly divide the integer with 10

i passed the example but it is a wrong answer to submission.
I wonder if my code is only suitable for short integer but not long.

Consider the test input:

1 Like

Hey @benily,

what if input is 10 ?

1 Like

oh… i see
therefore i should change the while loop to (a > 9)


1 Like

Just change while(a>10) to while(a>9)

1 Like

understand ! thanks

thanks :slight_smile: