Code: # this programs asks for temperature in Fahrenheit # and converts it to Ce
ID: 3628168 • Letter: C
Question
Code:# this programs asks for temperature in Fahrenheit
# and converts it to Celsius
.text
.globl main
main: # main has to be a global label
addu $s7, $0, $ra # save return address in a global register
# GETTING INPUT VALUE
la $a0,input # print message "input" on the console
li $v0,4
syscall
li $v0,5 #insert here code to get number entered on the console
syscall
# CALCULATING
addi $t0,$v0,-32 # a = a + (-32)
mul $t0,$t0,5 # a = a * 5
div $t0,$t0,9 # a= a/9
# PRINTING
la $a0,result # Store the string named 'result' in $a0
li $v0,4 #
syscall # __?
move $a0,$t0 # __?
li $v0,1 # __?
syscall # __?
.data
input: .asciiz " Enter temperature in Fahrenheit: "
result: .asciiz "The temperature in Celsius is: "
addu $ra, $0, $s7 # restore the return address
jr $ra # return to the main program
add $0, $0, $0 # nop (no operation)
1) what formula was used to convert temperature from Fahrenheit to Celsius?
Ok is the answer (((a+(-32)).5)/9)
If not, could i please get some help
Explanation / Answer
the formula used is : (°F - 32) x 5/9 = °C so you are correct.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.