Write a program that takes in an integer in the range 11-100 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is: 93 the output is: 93 92 91 90 89 88 Ex: If the input is: 11 the output is: 11 Ex: If the input is: 9 or any value not between 11 and 100 (inclusive), the output is: Input must be 11-100 this is what i have n = int(input()) if n > 100 or n < 11: print('Input must be 11-100') exit(0) while True: print(n, end=" ") first_digit = n // 10 second_digit = n % 10 if first_digit == second_digit: break n = n-1 my output is 93 92 91 90 89 88 but it needs to be 93 92 91 90 89 88
Write a program that takes in an integer in the range 11-100 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is: 93 the output is: 93 92 91 90 89 88 Ex: If the input is: 11 the output is: 11 Ex: If the input is: 9 or any value not between 11 and 100 (inclusive), the output is: Input must be 11-100 this is what i have n = int(input()) if n > 100 or n < 11: print('Input must be 11-100') exit(0) while True: print(n, end=" ") first_digit = n // 10 second_digit = n % 10 if first_digit == second_digit: break n = n-1 my output is 93 92 91 90 89 88 but it needs to be 93 92 91 90 89 88
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 15PE
Related questions
Question
100%
Write a program that takes in an integer in the range 11-100 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical.
Ex: If the input is:
93
the output is:
93
92
91
90
89
88
Ex: If the input is:
11
the output is:
11
Ex: If the input is:
9
or any value not between 11 and 100 (inclusive), the output is:
Input must be 11-100
this is what i have
n = int(input())
if n > 100 or n < 11:
print('Input must be 11-100')
exit(0)
while True:
print(n, end=" ")
first_digit = n // 10
second_digit = n % 10
if first_digit == second_digit:
break
n = n-1
my output is 93 92 91 90 89 88
but it needs to be
93
92
91
90
89
88
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr