205k views
4 votes
write a program that inputs one five-digit number, separates the number into its individual digits and displays the digits separated from one another by three spaces each. [hint: use combinations of integer division and the remainder operation.] for example, if the user types in 42139, the program should display

User Rasheena
by
8.0k points

1 Answer

3 votes

Answer:

Sure! Here's a MARIE assembly program that separates a five-digit number into its individual digits and displays them with three spaces in between each digit.

```

ORG 100

Input, 0

Store Number // Store the input number

Load Number

Div Thousand // Divide the number by 1000

Store Thousands // Store the thousands digit

Load Number

Subt Thousands // Subtract the thousands digit from the number

Div Hundred // Divide the result by 100

Store Hundreds // Store the hundreds digit

Load Number

Subt Thousands

Subt Hundreds // Subtract the thousands and hundreds digits from the number

Div Ten // Divide the result by 10

Store Tens // Store the tens digit

Load Number

Subt Thousands

Subt Hundreds

Subt Tens // Subtract the thousands, hundreds, and tens digits from the number

Store Units // Store the units digit

Load Thousands

Output // Output the thousands digit

Load Tens

Output // Output the tens digit

Load Units

Output // Output the units digit

Halt

Number, DEC 0

Thousands, DEC 0

Hundreds, DEC 0

Tens, DEC 0

Units, DEC 0

Thousand, DEC 1000

Hundred, DEC 100

Ten, DEC 10

END

```

To run this program, you can use a MARIE simulator or assembler. After entering a five-digit number, the program will separate the number into its individual digits and display them with three spaces in between each digit. For example, if the user inputs 42139, the program will display:

```

4 2 1 3 9

```

In which languages? Why you didn't specify that?

Step-by-step explanation:

User Kaykay
by
8.4k points