Computer Science, asked by miscacc4138, 5 months ago

Write a program to enter a 2-digit number and check if the ten's digit is twice the unit's digit.

Answers

Answered by anonymouslygreat
0

Answer:

In Python:

x = input('Enter a 2 digit number: ')

if int(x[0]) == 2 * int(x[1]):

 print('Yes')

else:

 print('No')

Explanation:

x[0] is the ten's digit. (input() returns a string)

x[1] is the one's digit.

x[0] and x[1] are strings, so we convert them to ints.

int(x[0] == int(x[1])

we want to see if the ten's digit (x[0]) is twice the unit's digit.

int(x[0]) == 2 * int(x[1])

our condition is formed, now we put it in an if-else statement.

if int(x[0]) == 2 * int(x[1]):

 print('Yes')

else:

 print('No')

If you are doing it in another programming language, try to apply the logic and instructions which I have given.

Similar questions