I was trying the following code
printf("%d", 010 % 10);
I was expecting it output be 0, but it is 8.
Why? Is there any way to get the last digit of an integer which is taken as input.
I was trying the following code
printf("%d", 010 % 10);
I was expecting it output be 0, but it is 8.
Why? Is there any way to get the last digit of an integer which is taken as input.
Any numeric literal in c or c++ starting with a zero will be interpreted as octal
So your calculation is 8 modulo 10, which is 8