InterviewSolution
| 1. |
How Do You Get The Last Digit Of An Integer? |
|
Answer» By USING MODULUS operator, number % 10 returns the last digit of the number, for example 2345%10 will return 5 and 567%10 will return 7. Similarly division operator can be used to get RID of last digit of a number e.g. 2345/10 will give 234 and 567/10 will return 56. This is an important technique to know and useful to solve problems LIKE number palindrome or reversing numbers. By using modulus operator, number % 10 returns the last digit of the number, for example 2345%10 will return 5 and 567%10 will return 7. Similarly division operator can be used to get rid of last digit of a number e.g. 2345/10 will give 234 and 567/10 will return 56. This is an important technique to know and useful to solve problems like number palindrome or reversing numbers. |
|