Ask Question
5 February, 04:49

Assume that an int variable x has already been declared,. write an expression whose value is the last (rightmost) digit of x.

+2
Answers (1)
  1. 5 February, 05:04
    0
    The last digit is in the tens place.

    Assuming Java:

    int expression = x - (x/10) * 10;

    Because Java truncates decimal, the decimal will be truncated after dividing by 10. For example, if

    int x = 5134

    then x/10 = 513

    Then x/10 * 10 = 5130

    so 5134 - 5130 = 4, which is last digit.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume that an int variable x has already been declared,. write an expression whose value is the last (rightmost) digit of x. ...” in 📗 Mathematics if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers