Question

22.23 LAB 9 C FALL 2019: Countdown until matching digits Write a program that takes in...

22.23 LAB 9 C FALL 2019: Countdown until matching digits

Write a program that takes in an integer in the range 20-98 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:

77

the output is:

77

Ex: If the input is:

15

or any value not between 20 and 98 (inclusive), the output is:

Input must be 20-98
0 0
Add a comment Improve this question Transcribed image text
Answer #1
n = int(input())
if(n>=20 and n<=98):
    while(not(n%10==n//10)):
        print(n,end=' ')
        n-=1
    print(n)
else:
    print("Input must be 20-98")

Output

93 93 92 91 90 89 88

Add a comment
Know the answer?
Add Answer to:
22.23 LAB 9 C FALL 2019: Countdown until matching digits Write a program that takes in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C please! 4.20 LAB: Countdown until matching digits Write a program that takes in an...

    In C please! 4.20 LAB: Countdown until matching digits Write a program that takes in an integer in the range 20-98 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: 77 the output is: 77 Ex: If the input is: 15 or any number not between 20 and 98 (inclusive),...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • Use C++ For this week’s lab you will write a program to read a data file...

    Use C++ For this week’s lab you will write a program to read a data file containing numerical values, one per line. The program should compute average of the numbers and also find the smallest and the largest value in the file. You may assume that the data file will have EXACTLY 100 integer values in it. Process all the values out of the data file. Show the average, smallest, largest, and the name of the data file in the...

  • The task involves writing a C++ program that determines the prime numbers between 1 and 100....

    The task involves writing a C++ program that determines the prime numbers between 1 and 100. The steps you should follow to identify the prime numbers are the following. 1. The number 1 is not a prime number, so it should be scratched. 2. Starting from the first prime number, which is 2, you scratch all the numbers that are the multiple of 2. You should not scratch out 2 itself. 3. The next number in the sequence after the...

  • (IN C LANGUAGE) 4.33 (Roman-Numeral Equivalent of Decimal Values) Write a program that prints a table...

    (IN C LANGUAGE) 4.33 (Roman-Numeral Equivalent of Decimal Values) Write a program that prints a table of all the Roman-numeral equivalents of the decimal numbers in the range 1 to 100. Decimal→→Roman↵ -------→→-----↵ 1→→I↵ 2→→II↵ 3→→III↵ 4→→IV↵ 5→→V↵ 6→→VI↵ 7→→VII↵ 8→→VIII↵ 9→→IX↵ 10→→X↵ 11→→XI↵ 12→→XII↵ 13→→XIII↵ 14→→XIV↵ 15→→XV↵ 16→→XVI↵ 17→→XVII↵ 18→→XVIII↵ 19→→XIX↵ 20→→XX↵ 21→→XXI↵ 22→→XXII↵ 23→→XXIII↵ 24→→XXIV↵ 25→→XXV↵ 26→→XXVI↵ 27→→XXVII↵ 28→→XXVIII↵ 29→→XXIX↵ 30→→XXX↵ 31→→XXXI↵ 32→→XXXII↵ 33→→XXXIII↵ 34→→XXXIV↵ 35→→XXXV↵ 36→→XXXVI↵ 37→→XXXVII↵ 38→→XXXVIII↵ 39→→XXXIX↵ 40→→XL↵ 41→→XLI↵ 42→→XLII↵ 43→→XLIII↵ 44→→XLIV↵ 45→→XLV↵ 46→→XLVI↵ 47→→XLVII↵...

  • Write a Java program, In this project, you are going to build a max-heap using array...

    Write a Java program, In this project, you are going to build a max-heap using array representation. In particular, your program should: • Implement two methods of building a max-heap. o Using sequential insertions (its time complexity: ?(?????), by successively applying the regular add method). o Using the optimal method (its time complexity: ?(?), the “smart” way we learned in class). For both methods, your implementations need to keep track of how many swaps (swapping parent and child) are required...

  • == Programming Assignment == For this assignment you will write a program that controls a set...

    == Programming Assignment == For this assignment you will write a program that controls a set of rovers and sends them commands to navigate on the Martian surface where they take samples. Each rover performs several missions and each mission follows the same sequence: deploy, perform one or more moves and scans, then return to base and report the results. While on a mission each rover needs to remember the scan results, in the same order as they were taken,...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT