Computer Science, asked by JOYNASKAR, 1 month ago

WAP to input any two numbers and find the unit digits (Last digit)of both Find out their sum and product. Print the sum and product

Answers

Answered by Equestriadash
10

The following co‎des have been written using Python.

\tt n1\ =\ int(in put("Enter\ a\ number:\ "))\\n2\ =\ int(in put("Enter\ a\ second\ number:\ "))\\ud1\ =\ str(n1)[-1]\\ud2\ =\ str(n2)[-1]\\print(ud1\ +\ ud2,\ "is\ the\ sum\ of\ the\ unit\ digits\ of",\ n1,\ "and",\ str(n2)\ +\ ".")\\print(ud1*ud2,\ "is\ the\ product\ of\ the\ unit\ digits\ of",\ n1,\ "and",\ str(n2)\ +\ ".")

We retrieve the numbers using the \tt in put() function. We use the \tt int() datatype since the data we're obtaining are numbers. We then perform slicing to get the units-digit, by converting the numbers to strings first, temporarily. The final output is shown using \tt print() statements.

To know more about string slicing, refer to the link below.

brainly.in/question/16088533

Similar questions