write a program to input three digit number and print the digits in reverse order (in python )
please solve with proper reason
Answers
Answered by
10
Answer:
n=int(input("Enter number: "))
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
print("Reverse of the number:",rev)
Explanation:
1.User must first enter the value and store it in a variable n.
2. The while loop is used and the last digit of the number is obtained by using the modulus operator.
3. The last digit is then stored at the one’s place, second last at the ten’s place and so on.
4. The last digit is then removed by truly dividing the number with 10.
5. This loop terminates when the value of the number is 0.
6. The reverse of the number is then printed
Answered by
0
Explanation:
thanks for your time and consideration
Similar questions
English,
6 months ago
Physics,
6 months ago
English,
6 months ago
Physics,
1 year ago
Political Science,
1 year ago
Social Sciences,
1 year ago