Computer Science, asked by MonidipMallick, 1 day ago

Write an Algorithm to input two numbers, both the numbers are two digits based, [3]

Now interchange the largest digits of both the numbers.

Eg : Number are : 12 and 36 , then output is : 16 and 31​

Answers

Answered by simran5144
0

Answer:

Examples :

Input : n = 687

Output : 21

Input : n = 12

Output : 3

General Algorithm for sum of digits in a given number:

Get the number

Declare a variable to store the sum and set it to 0

Repeat the next two steps till the number is not 0

Get the rightmost digit of the number with help of the remainder ‘%’ operator by dividing it by 10 and add it to sum.

Divide the number by 10 with help of ‘/’ operator to remove the rightmost digit.

Print or return the sum

Below are the solutions to get sum of the digits.

Similar questions