Ask Question
9 December, 11:53

Write a program that inputs a non negative integer, separates the integer into its digits and prints them separated by tabs each. For example, if the user types in 42339, the program should print:42339

+4
Answers (1)
  1. 9 December, 13:32
    0
    tab = ""

    number = int (input ("Enter a nonnegative integer: "))

    while number:

    digit = number % 10

    if len (str (number)) ! = 1:

    tab + = str (digit) + "/t"

    else:

    tab + = str (digit)

    number / / = 10

    print (tab[::-1])

    Explanation:

    * The code is in Python

    - Initialize an empty string to hold the digits

    - Ask the user for the input

    Inside the loop:

    - Get the digits of the number. If the length of the number is not 1 (If it is not the first digit), put a tab between the digits. Otherwise, just put the number (This will get the numbers from the last digit. If number is 123, it gets 3 first, then 2, then 1)

    - Print the string in reverse order
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that inputs a non negative integer, separates the integer into its digits and prints them separated by tabs each. For ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers