In this part, we will be manipulating "numerical" data at the machine level. The following code first prompts the user to enter numerical values one at a time. That is, the user enters a number, then hits enter, and the next the next number, hits enter, and so on. This keeps going until the user enters the number 0. For this and the next question, you can safely assume that the numbers entered are valid numbers (no characters) and each are also within the valid interval of numbers representable as a (singed) 32 bit integer. The code as of now just prints the total sum of this collection of numbers. .data prompt_for_input: .asciiz "Please enter your numbers, pressing enter after each, (0 to terminate):\n" prompt_for_output: .asciiz "Your quantity of interest is equal to: " .text main: # prompting the user with a message for a string input: li $v0, 4 la $a0, prompt_for_input syscall li $s0, 0 LOOP: li $v0, 5 syscall addu $s0, $s0, $v0 bne $v0, $zero, LOOP # prompting the user with a message for the processed output: li $v0, 4 la $a0, prompt_for_output syscall # printing the output addiu $v0, $zero, 1 addu $a0, $zero, $s0 syscall # Finish the programme: li $v0, 10 # syscall code for exit syscall # exit Modify the code, such that it, instead of the total sum, prints the requested value in the option that belong to you Your task: The maximum of the absolute values. For instance, if the numbers entered are [1, -7, -1, -3, 6, -2, 0], then the printed result must be 7.

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 19PE
icon
Related questions
Question

In this part, we will be manipulating "numerical" data at the machine level.

The following code first prompts the user to enter numerical values one at a time. That is, the user enters a number, then hits enter, and the next the next number, hits enter, and so on. This keeps going until the user enters the number 0. For this and the next question, you can safely assume that the numbers entered are valid numbers (no characters) and each are also within the valid interval of numbers representable as a (singed) 32 bit integer. The code as of now just prints the total sum of this collection of numbers.

.data prompt_for_input: .asciiz "Please enter your numbers, pressing enter after each, (0 to terminate):\n" prompt_for_output: .asciiz "Your quantity of interest is equal to: " .text main: # prompting the user with a message for a string input: li $v0, 4 la $a0, prompt_for_input syscall li $s0, 0 LOOP: li $v0, 5 syscall addu $s0, $s0, $v0 bne $v0, $zero, LOOP # prompting the user with a message for the processed output: li $v0, 4 la $a0, prompt_for_output syscall # printing the output addiu $v0, $zero, 1 addu $a0, $zero, $s0 syscall # Finish the programme: li $v0, 10 # syscall code for exit syscall # exit
Modify the code, such that it, instead of the total sum, prints the requested value in the option that belong to you
Your task:
The maximum of the absolute values. For instance, if the numbers entered are [1, -7, -1, -3, 6, -2, 0], then the printed result must be 7.
 
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning