Write a python program to find the middle digit of a 5-digit number.
Answers
Answered by
8
Question:-
- Write a python program to find the middle digit of a 5-digit number.
Program:-
n=int(input("Enter a 5 digit number: "))
if n>=10000 and n<=99999:
d=n//100
d=d%10
print("Middle digit is: ",d)
else:
print("Number is not a 5 digit number. ")
Logic:-
Consider a number, say 12345
It is a five digit number.
So,
d=n//100=12345//100=123
Now,
d=d%10
Or,
d=123%10=3
Hence, 3 is the middle digit.
In this way the program works.
Answered by
0
Explanation:
this is the answer..
.....
Attachments:
Similar questions